From 898235c4864df66aa7f6d32bc2a8b8551040ce1e Mon Sep 17 00:00:00 2001 From: brianosman Date: Wed, 6 Apr 2016 07:38:23 -0700 Subject: SkSurfaceProps now has a gamma-correct ("AllowSRGBInputs") flag. That's propagated in a few places so that the backend can do the right thing for L32 vs S32 mode. Also added SkSurfaceProps to SkSpecialImage, so that Image -> Surface conversion can preserve the desired behavior during filtering. Many small changes, including a bunch of comments about places where we may be losing information right now. My approach was to ensure that if anything fails, it will always fall back to "legacy" mode - gamma-correctness is opt-in, so I'll just have to feed things through as missing cases are exposed. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1838953007 Review URL: https://codereview.chromium.org/1845283003 --- gm/surface.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'gm/surface.cpp') diff --git a/gm/surface.cpp b/gm/surface.cpp index 901e324397..e104cb5ecf 100644 --- a/gm/surface.cpp +++ b/gm/surface.cpp @@ -22,7 +22,7 @@ static sk_sp make_shader() { } static sk_sp make_surface(GrContext* ctx, const SkImageInfo& info, SkPixelGeometry geo, - int disallowAA, int disallowDither) { + int disallowAA, int disallowDither, bool allowSRGBInputs) { uint32_t flags = 0; if (disallowAA) { flags |= SkSurfaceProps::kDisallowAntiAlias_Flag; @@ -30,6 +30,9 @@ static sk_sp make_surface(GrContext* ctx, const SkImageInfo& info, Sk if (disallowDither) { flags |= SkSurfaceProps::kDisallowDither_Flag; } + if (allowSRGBInputs) { + flags |= SkSurfaceProps::kAllowSRGBInputs_Flag; + } SkSurfaceProps props(flags, geo); if (ctx) { @@ -74,7 +77,10 @@ protected: GrContext* ctx = canvas->getGrContext(); // must be opaque to have a hope of testing LCD text - const SkImageInfo info = SkImageInfo::MakeN32(W, H, kOpaque_SkAlphaType); + const SkImageInfo info = SkImageInfo::MakeN32(W, H, kOpaque_SkAlphaType, + canvas->imageInfo().profileType()); + SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType); + bool allowSRGBInputs = canvas->getProps(&canvasProps) && canvasProps.allowSRGBInputs(); const struct { SkPixelGeometry fGeo; @@ -92,7 +98,8 @@ protected: for (int disallowDither = 0; disallowDither <= 1; ++disallowDither) { SkScalar y = 0; for (size_t i = 0; i < SK_ARRAY_COUNT(rec); ++i) { - auto surface(make_surface(ctx, info, rec[i].fGeo, disallowAA, disallowDither)); + auto surface(make_surface(ctx, info, rec[i].fGeo, disallowAA, disallowDither, + allowSRGBInputs)); test_draw(surface->getCanvas(), rec[i].fLabel); surface->draw(canvas, x, y, nullptr); y += H; -- cgit v1.2.3