本文整理汇总了C++中SkPictureRecorder::finishRecordingAsDrawable方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPictureRecorder::finishRecordingAsDrawable方法的具体用法?C++ SkPictureRecorder::finishRecordingAsDrawable怎么用?C++ SkPictureRecorder::finishRecordingAsDrawable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPictureRecorder
的用法示例。
在下文中一共展示了SkPictureRecorder::finishRecordingAsDrawable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: proc
// Test the kReturnNullForEmpty_FinishFlag option when recording
//
DEF_TEST(Picture_RecordEmpty, r) {
const SkRect cull = SkRect::MakeWH(100, 100);
CanvasProc procs[] { empty_ops, clip_ops, matrix_ops, matrixclip_ops };
for (auto proc : procs) {
{
SkPictureRecorder rec;
proc(rec.beginRecording(cull));
sk_sp<SkPicture> pic = rec.finishRecordingAsPicture(0);
REPORTER_ASSERT(r, pic.get());
REPORTER_ASSERT(r, pic->approximateOpCount() == 0);
}
{
SkPictureRecorder rec;
proc(rec.beginRecording(cull));
sk_sp<SkPicture> pic = rec.finishRecordingAsPicture(
SkPictureRecorder::kReturnNullForEmpty_FinishFlag);
REPORTER_ASSERT(r, !pic.get());
}
{
SkPictureRecorder rec;
proc(rec.beginRecording(cull));
sk_sp<SkDrawable> dr = rec.finishRecordingAsDrawable(0);
REPORTER_ASSERT(r, dr.get());
}
{
SkPictureRecorder rec;
proc(rec.beginRecording(cull));
sk_sp<SkDrawable> dr = rec.finishRecordingAsDrawable(
SkPictureRecorder::kReturnNullForEmpty_FinishFlag);
REPORTER_ASSERT(r, !dr.get());
}
}
}
示例2: 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();
}
示例3: playback
sk_sp<SkFlattenable> SkRecordedDrawable::CreateProc(SkReadBuffer& buffer) {
// Read the bounds.
SkRect bounds;
buffer.readRect(&bounds);
// Unflatten into a SkPictureData.
SkPictInfo info;
info.fCullRect = bounds;
SkAutoTDelete<SkPictureData> pictureData(SkPictureData::CreateFromBuffer(buffer, info));
if (!pictureData) {
return nullptr;
}
// Create a drawable.
SkPicturePlayback playback(pictureData);
SkPictureRecorder recorder;
playback.draw(recorder.beginRecording(bounds), nullptr, &buffer);
return recorder.finishRecordingAsDrawable();
}
示例4: readBuffer
DEF_TEST(FlattenRecordedDrawable, r) {
// Record a set of canvas draw commands
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(1000.0f, 1000.0f);
SkPaint paint;
paint.setColor(SK_ColorGREEN);
canvas->drawPoint(42.0f, 17.0f, paint);
paint.setColor(SK_ColorRED);
canvas->drawPaint(paint);
SkPaint textPaint;
textPaint.setColor(SK_ColorBLUE);
canvas->drawString("TEXT", 467.0f, 100.0f, textPaint);
// Draw some drawables as well
sk_sp<SkDrawable> drawable(new IntDrawable(1, 2, 3, 4));
sk_sp<RootDrawable> root(new RootDrawable(5, 6, 7, 8, paint, 9, 10, 11, 12, drawable.get()));
canvas->drawDrawable(root.get(), 747.0f, 242.0f);
sk_sp<PaintDrawable> paintDrawable(new PaintDrawable(paint));
canvas->drawDrawable(paintDrawable.get(), 500.0, 500.0f);
sk_sp<CompoundDrawable> comDrawable(new CompoundDrawable(13, 14, 15, 16, textPaint));
canvas->drawDrawable(comDrawable.get(), 10.0f, 10.0f);
// Serialize the recorded drawable
sk_sp<SkDrawable> recordedDrawable = recorder.finishRecordingAsDrawable();
SkBinaryWriteBuffer writeBuffer;
writeBuffer.writeFlattenable(recordedDrawable.get());
// Copy the contents of the write buffer into a read buffer
sk_sp<SkData> data = SkData::MakeUninitialized(writeBuffer.bytesWritten());
writeBuffer.writeToMemory(data->writable_data());
SkReadBuffer readBuffer(data->data(), data->size());
register_test_drawables(readBuffer);
// Deserialize and verify the drawable
sk_sp<SkDrawable> out((SkDrawable*)readBuffer.readFlattenable(SkFlattenable::kSkDrawable_Type));
REPORTER_ASSERT(r, out);
REPORTER_ASSERT(r, !strcmp("SkRecordedDrawable", out->getTypeName()));
}