本文整理汇总了C++中SkPictureRecorder::beginRecording方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPictureRecorder::beginRecording方法的具体用法?C++ SkPictureRecorder::beginRecording怎么用?C++ SkPictureRecorder::beginRecording使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPictureRecorder
的用法示例。
在下文中一共展示了SkPictureRecorder::beginRecording方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// getRecordingCanvas() should return a SkCanvas when recording, null when not recording.
DEF_TEST(Picture_getRecordingCanvas, r) {
SkPictureRecorder rec;
REPORTER_ASSERT(r, !rec.getRecordingCanvas());
for (int i = 0; i < 3; i++) {
rec.beginRecording(100, 100);
REPORTER_ASSERT(r, rec.getRecordingCanvas());
rec.finishRecordingAsPicture();
REPORTER_ASSERT(r, !rec.getRecordingCanvas());
}
}
示例2: draw
void draw(SkCanvas* canvas) {
SkPictureRecorder recorder;
SkCanvas* pictureCanvas = recorder.beginRecording({0, 0, 256, 256});
SkPaint paint;
pictureCanvas->drawRect(SkRect::MakeWH(200, 200), paint);
paint.setColor(SK_ColorWHITE);
pictureCanvas->drawRect(SkRect::MakeLTRB(20, 20, 180, 180), paint);
sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture();
picture->playback(canvas);
}
示例3: test_replacements
// Test out the layer replacement functionality with and w/o a BBH
void test_replacements(skiatest::Reporter* r, GrContext* context, bool doReplace) {
sk_sp<SkPicture> pic;
{
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntToScalar(kHeight));
SkPaint paint;
canvas->saveLayer(nullptr, &paint);
canvas->clear(SK_ColorRED);
canvas->restore();
canvas->drawRect(SkRect::MakeWH(SkIntToScalar(kWidth / 2), SkIntToScalar(kHeight / 2)),
SkPaint());
pic = recorder.finishRecordingAsPicture();
}
SkAutoTUnref<GrTexture> texture;
SkPaint paint;
GrLayerCache* layerCache = context->getLayerCache();
if (doReplace) {
int key[1] = { 0 };
GrCachedLayer* layer = layerCache->findLayerOrCreate(pic->uniqueID(), 0, 2,
SkIRect::MakeWH(kWidth, kHeight),
SkIRect::MakeWH(kWidth, kHeight),
SkMatrix::I(), key, 1, &paint);
GrSurfaceDesc desc;
desc.fConfig = kSkia8888_GrPixelConfig;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fWidth = kWidth;
desc.fHeight = kHeight;
desc.fSampleCnt = 0;
// Giving the texture some initial data so the Gpu (specifically vulkan) does not complain
// when reading from an uninitialized texture.
SkAutoTMalloc<uint32_t> srcBuffer(kWidth*kHeight);
memset(srcBuffer.get(), 0, kWidth*kHeight*sizeof(uint32_t));
texture.reset(context->textureProvider()->createTexture(
desc, SkBudgeted::kNo, srcBuffer.get(), 0));
layer->setTexture(texture, SkIRect::MakeWH(kWidth, kHeight), false);
}
SkRecord rerecord;
SkRecorder canvas(&rerecord, kWidth, kHeight);
GrRecordReplaceDraw(pic.get(), &canvas, layerCache, SkMatrix::I(), nullptr/*callback*/);
int numLayers = count_instances_of_type<SkRecords::SaveLayer>(rerecord);
if (doReplace) {
REPORTER_ASSERT(r, 0 == numLayers);
} else {
REPORTER_ASSERT(r, 1 == numLayers);
}
}
示例4: test_typeface
static void test_typeface(skiatest::Reporter* reporter) {
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(10, 10);
SkPaint paint;
paint.setTypeface(SkTypeface::CreateFromName("Arial", SkTypeface::kItalic));
canvas->drawText("Q", 1, 0, 10, paint);
sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, picture->hasText());
SkDynamicMemoryWStream stream;
picture->serialize(&stream);
}
示例5: paintContents
void LinkHighlight::paintContents(WebDisplayItemList* webDisplayItemList, const WebRect& webClipRect, WebContentLayerClient::PaintingControlSetting paintingControl)
{
if (!m_node || !m_node->layoutObject())
return;
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(webClipRect.width, webClipRect.height);
canvas->translate(-webClipRect.x, -webClipRect.y);
paintContents(canvas, webClipRect, paintingControl);
webDisplayItemList->appendDrawingItem(recorder.endRecording());
}
示例6: DrawPictureTestStep
static void DrawPictureTestStep(SkCanvas* canvas, const TestData& d,
skiatest::Reporter*, CanvasTestStep*) {
SkPictureRecorder recorder;
SkCanvas* testCanvas = recorder.beginRecording(SkIntToScalar(d.fWidth), SkIntToScalar(d.fHeight),
nullptr, 0);
testCanvas->scale(SkIntToScalar(2), SkIntToScalar(1));
testCanvas->clipRect(d.fRect);
testCanvas->drawRect(d.fRect, d.fPaint);
canvas->drawPicture(recorder.finishRecordingAsPicture());
}
示例7: onNewPictureSnapshot
SkPicture* SkDrawable::onNewPictureSnapshot() {
SkPictureRecorder recorder;
const SkRect bounds = this->getBounds();
SkCanvas* canvas = recorder.beginRecording(bounds, nullptr, 0);
this->draw(canvas);
if (false) {
draw_bbox(canvas, bounds);
}
return recorder.endRecording();
}
示例8: rerecord_with_tilegrid
static SkPicture* rerecord_with_tilegrid(SkPicture& src) {
SkTileGridFactory::TileGridInfo info;
info.fTileInterval.set(FLAGS_tile, FLAGS_tile);
info.fMargin.setEmpty();
info.fOffset.setZero();
SkTileGridFactory factory(info);
SkPictureRecorder recorder;
src.draw(recorder.beginRecording(src.width(), src.height(), &factory));
return recorder.endRecording();
}
示例9: playback
sk_sp<SkPicture> SkPicture::Forwardport(const SkPictInfo& info,
const SkPictureData* data,
const SkReadBuffer* buffer) {
if (!data) {
return nullptr;
}
SkPicturePlayback playback(data);
SkPictureRecorder r;
playback.draw(r.beginRecording(info.fCullRect), nullptr/*no callback*/, buffer);
return r.finishRecordingAsPicture();
}
示例10: buildBBoxHierarchy
/** Converts fPicture to a picture that uses a BBoxHierarchy.
* PictureRenderer subclasses that are used to test picture playback
* should call this method during init.
*/
void PictureRenderer::buildBBoxHierarchy() {
SkASSERT(NULL != fPicture);
if (kNone_BBoxHierarchyType != fBBoxHierarchyType && NULL != fPicture) {
SkAutoTDelete<SkBBHFactory> factory(this->getFactory());
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(fPicture->width(), fPicture->height(),
factory.get(),
this->recordFlags());
fPicture->draw(canvas);
fPicture.reset(recorder.endRecording());
}
}
示例11: HTView
HTView() {
SkRandom rand;
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(SkRect::MakeWH(W, H));
for (int i = 0; i < N; ++i) {
fArray[i].fDrawable = new HTDrawable(rand);
canvas->drawDrawable(fArray[i].fDrawable);
fArray[i].fDrawable->unref();
}
fRoot = recorder.finishRecordingAsDrawable();
}
示例12: onDraw
void RecordingBench::onDraw(const int loops, SkCanvas*) {
SkRTreeFactory factory;
const SkScalar w = fSrc->cullRect().width(),
h = fSrc->cullRect().height();
for (int i = 0; i < loops; i++) {
SkPictureRecorder recorder;
fSrc->playback(recorder.beginRecording(w, h, fUseBBH ? &factory : NULL,
SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag));
SkSafeUnref(recorder.endRecording());
}
}
示例13: makePicture
void makePicture() {
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(100, 100);
canvas->clear(0x00000000);
SkPaint paint;
paint.setAntiAlias(true);
paint.setColor(0xFFFFFFFF);
paint.setTextSize(SkIntToScalar(96));
const char* str = "e";
canvas->drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), paint);
fPicture.reset(recorder.endRecording());
}
示例14: serialized_picture_from_bitmap
static SkData* serialized_picture_from_bitmap(const SkBitmap& bitmap) {
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(bitmap.width()),
SkIntToScalar(bitmap.height()));
canvas->drawBitmap(bitmap, 0, 0);
SkAutoTUnref<SkPicture> picture(recorder.endRecording());
SkDynamicMemoryWStream wStream;
sk_tool_utils::PngPixelSerializer serializer;
picture->serialize(&wStream, &serializer);
return wStream.copyToData();
}
示例15: DrawPictureTestStep
static void DrawPictureTestStep(SkCanvas* canvas, const TestData& d,
skiatest::Reporter*, CanvasTestStep*) {
SkPictureRecorder recorder;
SkCanvas* testCanvas = recorder.beginRecording(SkIntToScalar(d.fWidth), SkIntToScalar(d.fHeight),
NULL, 0);
testCanvas->scale(SkIntToScalar(2), SkIntToScalar(1));
testCanvas->clipRect(d.fRect);
testCanvas->drawRect(d.fRect, d.fPaint);
SkAutoTUnref<SkPicture> testPicture(recorder.endRecording());
canvas->drawPicture(testPicture);
}