Fix image info checking for always-opaque color types
The old code overlooked 101010x and 888x. The GPU code for
readPixels tried to enfore this, but incorrectly, and the
writePixels code missed it entirely.
Bug: skia:
Change-Id: Ib69473703f2ae7604d4b21ec6728b7d764becd9a
Reviewed-on: https://skia-review.googlesource.com/c/161148
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index b29454c..488a364 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -565,7 +565,9 @@
if (kUnknown_SkColorType == srcSkColorType || kUnknown_SkColorType == dstSkColorType) {
return false;
}
- auto srcAlphaType = premul ? kUnpremul_SkAlphaType : kPremul_SkAlphaType;
+ auto srcAlphaType = SkColorTypeIsAlwaysOpaque(srcSkColorType)
+ ? kOpaque_SkAlphaType
+ : (premul ? kUnpremul_SkAlphaType : kPremul_SkAlphaType);
SkPixmap src(SkImageInfo::Make(width, height, srcSkColorType, srcAlphaType,
sk_ref_sp(srcColorSpace)),
buffer, rowBytes);
@@ -746,7 +748,7 @@
auto tempII = SkImageInfo::Make(width, height, srcSkColorType, tempAT,
src->colorSpaceInfo().refColorSpace());
SkASSERT(!unpremul || !SkColorTypeIsAlwaysOpaque(dstSkColorType));
- auto finalAT = SkColorTypeIsAlwaysOpaque(srcSkColorType)
+ auto finalAT = SkColorTypeIsAlwaysOpaque(dstSkColorType)
? kOpaque_SkAlphaType
: unpremul ? kUnpremul_SkAlphaType : kPremul_SkAlphaType;
auto finalII =