本文整理汇总了C++中SkImageInfo::flatten方法的典型用法代码示例。如果您正苦于以下问题:C++ SkImageInfo::flatten方法的具体用法?C++ SkImageInfo::flatten怎么用?C++ SkImageInfo::flatten使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkImageInfo
的用法示例。
在下文中一共展示了SkImageInfo::flatten方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_flatten
static void test_flatten(skiatest::Reporter* reporter, const SkImageInfo& info) {
// just need a safe amount of storage, but ensure that it is 4-byte aligned.
int32_t storage[(sizeof(SkImageInfo)*2) / sizeof(int32_t)];
SkBinaryWriteBuffer wb(storage, sizeof(storage));
info.flatten(wb);
SkASSERT(wb.bytesWritten() < sizeof(storage));
SkReadBuffer rb(storage, wb.bytesWritten());
// pick a noisy byte pattern, so we ensure that unflatten sets all of our fields
SkImageInfo info2 = SkImageInfo::Make(0xB8, 0xB8, (SkColorType) 0xB8, (SkAlphaType) 0xB8);
info2.unflatten(rb);
REPORTER_ASSERT(reporter, rb.offset() == wb.bytesWritten());
REPORTER_ASSERT(reporter, info == info2);
}
示例2: test_flatten
static void test_flatten(skiatest::Reporter* reporter, const SkImageInfo& info) {
// Need a safe amount of 4-byte aligned storage. Note that one of the test ICC profiles
// is ~7500 bytes.
const size_t storageBytes = 8000;
SkAutoTMalloc<uint32_t> storage(storageBytes / sizeof(uint32_t));
SkBinaryWriteBuffer wb(storage.get(), storageBytes);
info.flatten(wb);
SkASSERT(wb.bytesWritten() < storageBytes);
SkReadBuffer rb(storage.get(), wb.bytesWritten());
// pick a noisy byte pattern, so we ensure that unflatten sets all of our fields
SkImageInfo info2 = SkImageInfo::Make(0xB8, 0xB8, (SkColorType) 0xB8, (SkAlphaType) 0xB8);
info2.unflatten(rb);
REPORTER_ASSERT(reporter, rb.offset() == wb.bytesWritten());
REPORTER_ASSERT(reporter, info == info2);
}