add a couple bitmap cases to P3 GM

This checks drawBitmap() and a few ways to create P3 bitmaps.

Change-Id: I6f891c641a44249d7562f2f5ddeed8cbaa40ad40
Reviewed-on: https://skia-review.googlesource.com/154863
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
Mike Klein 2018-09-17 12:39:09 -04:00 committed by Skia Commit-Bot
parent c03716dd76
commit 62bd12f723

View File

@ -141,7 +141,7 @@ static void compare_pixel(const char* label,
}
}
DEF_SIMPLE_GM(p3, canvas, 450, 500) {
DEF_SIMPLE_GM(p3, canvas, 450, 800) {
auto p3 = SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma,
SkColorSpace::kDCIP3_D65_Gamut);
@ -149,9 +149,8 @@ DEF_SIMPLE_GM(p3, canvas, 450, 500) {
{
SkPaint paint;
paint.setColor4f({1,0,0,1}, p3.get());
canvas->drawRect({10,10,70,70}, SkPaint{});
canvas->drawRect({10,10,70,70}, paint);
canvas->drawRect({10,10,70,70}, paint);
compare_pixel("drawRect P3 red ",
canvas, 10,10,
{1,0,0,1}, p3.get());
@ -159,6 +158,56 @@ DEF_SIMPLE_GM(p3, canvas, 450, 500) {
canvas->translate(0,80);
// Draw a P3 red bitmap, using a draw.
{
SkBitmap bm;
bm.allocPixels(SkImageInfo::Make(60,60, kRGBA_F16_SkColorType, kPremul_SkAlphaType, p3));
SkPaint paint;
paint.setColor4f({1,0,0,1}, p3.get());
SkCanvas{bm}.drawPaint(paint);
canvas->drawBitmap(bm, 10,10);
compare_pixel("drawBitmap P3 red, from drawPaint",
canvas, 10,10,
{1,0,0,1}, p3.get());
}
canvas->translate(0,80);
// Draw a P3 red bitmap, using SkBitmap::eraseColor().
{
SkBitmap bm;
bm.allocPixels(SkImageInfo::Make(60,60, kRGBA_F16_SkColorType, kPremul_SkAlphaType, p3));
bm.eraseColor(0xffff0000/*in P3*/);
canvas->drawBitmap(bm, 10,10);
compare_pixel("drawBitmap P3 red, from SkBitmap::eraseColor()",
canvas, 10,10,
{1,0,0,1}, p3.get());
}
canvas->translate(0,80);
// Draw a P3 red bitmap, using SkPixmap::erase().
{
SkBitmap bm;
bm.allocPixels(SkImageInfo::Make(60,60, kRGBA_F16_SkColorType, kPremul_SkAlphaType, p3));
// At the moment only SkPixmap has an erase() that takes an SkColor4f.
SkPixmap pm;
SkAssertResult(bm.peekPixels(&pm));
SkAssertResult(pm.erase({1,0,0,1} /*in p3*/));
canvas->drawBitmap(bm, 10,10);
compare_pixel("drawBitmap P3 red, from SkPixmap::erase",
canvas, 10,10,
{1,0,0,1}, p3.get());
}
canvas->translate(0,80);
// Draw a gradient from P3 red to P3 green, and check the corners.
{
@ -169,9 +218,7 @@ DEF_SIMPLE_GM(p3, canvas, 450, 500) {
paint.setShader(SkGradientShader::MakeLinear(points, colors, p3,
nullptr, SK_ARRAY_COUNT(colors),
SkShader::kClamp_TileMode));
canvas->drawRect({10,10,70,70}, SkPaint{});
canvas->drawRect({10,10,70,70}, paint);
canvas->save();
compare_pixel("gradient P3 red",
canvas, 10,10,