本文整理汇总了C++中SkPixmap::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPixmap::erase方法的具体用法?C++ SkPixmap::erase怎么用?C++ SkPixmap::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPixmap
的用法示例。
在下文中一共展示了SkPixmap::erase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: erase
bool SkPixmap::erase(const SkColor4f& origColor, const SkIRect* subset) const {
SkPixmap pm;
if (subset) {
if (!this->extractSubset(&pm, *subset)) {
return false;
}
} else {
pm = *this;
}
const SkColor4f color = origColor.pin();
if (kRGBA_F16_SkColorType != pm.colorType()) {
Sk4f c4 = Sk4f::Load(color.vec());
SkColor c;
(c4 * Sk4f(255) + Sk4f(0.5f)).store(&c);
return pm.erase(c);
}
const uint64_t half4 = color.premul().toF16();
for (int y = 0; y < pm.height(); ++y) {
sk_memset64(pm.writable_addr64(0, y), half4, pm.width());
}
return true;
}
示例2: SkColorGetA
// Test that erase+getColor round trips with RGBA_F16 pixels.
DEF_TEST(Bitmap_erase_f16_erase_getColor, r) {
SkRandom random;
SkPixmap pm;
SkBitmap bm;
bm.allocPixels(SkImageInfo::Make(1, 1, kRGBA_F16_SkColorType, kPremul_SkAlphaType));
REPORTER_ASSERT(r, bm.peekPixels(&pm));
for (unsigned i = 0; i < 0x100; ++i) {
// Test all possible values of blue component.
SkColor color1 = (SkColor)((random.nextU() & 0xFFFFFF00) | i);
// Test all possible values of alpha component.
SkColor color2 = (SkColor)((random.nextU() & 0x00FFFFFF) | (i << 24));
for (SkColor color : {color1, color2}) {
pm.erase(color);
if (SkColorGetA(color) != 0) {
REPORTER_ASSERT(r, color == pm.getColor(0, 0));
} else {
REPORTER_ASSERT(r, 0 == SkColorGetA(pm.getColor(0, 0)));
}
}
}
}