当前位置: 首页>>代码示例>>C++>>正文


C++ SkPictureRecorder::beginRecording方法代码示例

本文整理汇总了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());
    }
}
开发者ID:03050903,项目名称:skia,代码行数:11,代码来源:PictureTest.cpp

示例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);
}
开发者ID:HalCanary,项目名称:skia-hc,代码行数:10,代码来源:Picture_playback.cpp

示例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);
    }
}
开发者ID:OwenTan,项目名称:skia,代码行数:56,代码来源:RecordReplaceDrawTest.cpp

示例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);
}
开发者ID:zwdsjl,项目名称:skia,代码行数:11,代码来源:PictureTest.cpp

示例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());
}
开发者ID:kingysu,项目名称:blink-crosswalk,代码行数:11,代码来源:LinkHighlight.cpp

示例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());
}
开发者ID:MIPS,项目名称:external-skia,代码行数:11,代码来源:CanvasTest.cpp

示例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();
}
开发者ID:Crawping,项目名称:chromium_extract,代码行数:11,代码来源:SkDrawable.cpp

示例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();
}
开发者ID:Adenilson,项目名称:skia,代码行数:11,代码来源:bench_playback.cpp

示例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();
}
开发者ID:BertiKarsunke,项目名称:skia,代码行数:11,代码来源:SkPicture.cpp

示例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());
    }
}
开发者ID:miaoshunping,项目名称:skia,代码行数:16,代码来源:PictureRenderer.cpp

示例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();
    }
开发者ID:03050903,项目名称:skia,代码行数:12,代码来源:SampleHT.cpp

示例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());
    }
}
开发者ID:Arternis,项目名称:skia,代码行数:12,代码来源:RecordingBench.cpp

示例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());
 }
开发者ID:llluiop,项目名称:skia,代码行数:12,代码来源:pictureimagefilter.cpp

示例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();
}
开发者ID:WangCrystal,项目名称:skia,代码行数:12,代码来源:PictureTest.cpp

示例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);
}
开发者ID:mariospr,项目名称:chromium-browser,代码行数:12,代码来源:CanvasTest.cpp


注:本文中的SkPictureRecorder::beginRecording方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。