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>
This commit is contained in:
Brian Osman 2018-10-10 17:12:04 -04:00 committed by Skia Commit-Bot
parent ff4d9c817b
commit 9835dd51b3
2 changed files with 5 additions and 4 deletions

View File

@ -106,8 +106,7 @@ static inline bool SkImageInfoIsValid(const SkImageInfo& info) {
return false;
}
if (kOpaque_SkAlphaType != info.alphaType() &&
(kRGB_565_SkColorType == info.colorType() || kGray_8_SkColorType == info.colorType())) {
if (kOpaque_SkAlphaType != info.alphaType() && SkColorTypeIsAlwaysOpaque(info.colorType())) {
return false;
}

View File

@ -565,7 +565,9 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceContext* dst, int left, int top,
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 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceContext* src, int left, int top,
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 =