本文整理汇总了C++中SkDrawable::getTypeName方法的典型用法代码示例。如果您正苦于以下问题:C++ SkDrawable::getTypeName方法的具体用法?C++ SkDrawable::getTypeName怎么用?C++ SkDrawable::getTypeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkDrawable
的用法示例。
在下文中一共展示了SkDrawable::getTypeName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readBuffer
DEF_TEST(FlattenDrawable, r) {
// Create and serialize the test drawable
sk_sp<SkDrawable> drawable(new IntDrawable(1, 2, 3, 4));
SkPaint paint;
paint.setColor(SK_ColorBLUE);
sk_sp<RootDrawable> root(new RootDrawable(5, 6, 7, 8, paint, 9, 10, 11, 12, drawable.get()));
SkBinaryWriteBuffer writeBuffer;
writeBuffer.writeFlattenable(root.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("RootDrawable", out->getTypeName()));
RootDrawable* rootOut = (RootDrawable*) out.get();
REPORTER_ASSERT(r, 5 == rootOut->compoundDrawable()->intDrawable()->a());
REPORTER_ASSERT(r, 6 == rootOut->compoundDrawable()->intDrawable()->b());
REPORTER_ASSERT(r, 7 == rootOut->compoundDrawable()->intDrawable()->c());
REPORTER_ASSERT(r, 8 == rootOut->compoundDrawable()->intDrawable()->d());
REPORTER_ASSERT(r, SK_ColorBLUE ==
rootOut->compoundDrawable()->paintDrawable()->paint().getColor());
REPORTER_ASSERT(r, 9 == rootOut->intDrawable()->a());
REPORTER_ASSERT(r, 10 == rootOut->intDrawable()->b());
REPORTER_ASSERT(r, 11 == rootOut->intDrawable()->c());
REPORTER_ASSERT(r, 12 == rootOut->intDrawable()->d());
// Note that we can still recognize the generic drawable as an IntDrawable
SkDrawable* generic = rootOut->drawable();
REPORTER_ASSERT(r, !strcmp("IntDrawable", generic->getTypeName()));
IntDrawable* integer = (IntDrawable*) generic;
REPORTER_ASSERT(r, 1 == integer->a());
REPORTER_ASSERT(r, 2 == integer->b());
REPORTER_ASSERT(r, 3 == integer->c());
REPORTER_ASSERT(r, 4 == integer->d());
}