diff options
author | Mike Reed <reed@google.com> | 2018-02-09 17:35:29 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-10 01:00:41 +0000 |
commit | 1617899b677050d3db63c3770c406e16501f356c (patch) | |
tree | e8aaf4b7503803ce8f18d7e49c103bb4109bb367 /gm | |
parent | e1053eaca2447b79fb878fc7fc54b3767c03bc8b (diff) |
add helper to know when a colortype is always opaque
Now that surface creation is more picky about its imageinfo, we need to
allow clients to know when they should clean-up their alphatype (like
our own gm)
Bug: skia:
Change-Id: Ic110c75769e0154a8343d7e2160d3351f02cf48f
Reviewed-on: https://skia-review.googlesource.com/106320
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'gm')
-rw-r--r-- | gm/imagealphathreshold.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gm/imagealphathreshold.cpp b/gm/imagealphathreshold.cpp index 3783bfcb3a..4bdf6eb5a2 100644 --- a/gm/imagealphathreshold.cpp +++ b/gm/imagealphathreshold.cpp @@ -89,7 +89,7 @@ private: // Create a 'width' x 'height' SkSurface that matches the colorType of 'canvas' as // best we can static sk_sp<SkSurface> make_color_matching_surface(SkCanvas* canvas, int width, int height, - SkAlphaType alphaType) { + SkAlphaType at) { SkColorType ct = canvas->imageInfo().colorType(); sk_sp<SkColorSpace> cs(canvas->imageInfo().refColorSpace()); @@ -98,9 +98,11 @@ static sk_sp<SkSurface> make_color_matching_surface(SkCanvas* canvas, int width, // For backends that aren't yet color-space aware we just fallback to N32. ct = kN32_SkColorType; cs = nullptr; + } else if (SkColorTypeIsAlwaysOpaque(ct)) { + at = kOpaque_SkAlphaType; } - SkImageInfo info = SkImageInfo::Make(width, height, ct, alphaType, std::move(cs)); + SkImageInfo info = SkImageInfo::Make(width, height, ct, at, std::move(cs)); return sk_tool_utils::makeSurface(canvas, info); } |