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:
parent
ff4d9c817b
commit
9835dd51b3
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 =
|
||||
|
Loading…
Reference in New Issue
Block a user