Fix SkColorSpaceXform F16 behavior

After changing the matrix representation, we are no longer guaranteed
that the "a" in "rgba" is zeroed in store_f16_1() opaque.

This fixed Gold:
https://gold.skia.org/search?blame=26a0543579cf7473de2099ce0d056ac8aba83811&head=true&include=false&limit=50&neg=false&pos=false&query=source_type%3DcolorImage&unt=true

Also tacked on an optimization.  No need to load alpha when the image
is opaque.

BUG=skia:

Change-Id: I28d80c486b6644eee4a38a7a70f94eb51474e4b0
Reviewed-on: https://skia-review.googlesource.com/6738
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Matt Sarett <msarett@google.com>
This commit is contained in:
Matt Sarett 2017-01-09 09:14:28 -05:00 committed by Skia Commit-Bot
parent 9a34b8c779
commit e980155dd5

View File

@ -773,6 +773,7 @@ static AI void store_f16_1_opaque(void* dst, const uint32_t* src,
const uint8_t* const[3]) {
uint64_t tmp;
SkFloatToHalf_finite_ftz(rgba).store(&tmp);
tmp &= 0x0000FFFFFFFFFFFF;
tmp |= static_cast<uint64_t>(SK_Half1) << 48;
*((uint64_t*) dst) = tmp;
}
@ -861,7 +862,7 @@ static void color_xform_RGBA(void* dst, const void* vsrc, int len,
LoadFn load;
Load1Fn load_1;
const bool kLoadAlpha = (kPremul_SkAlphaType == kAlphaType) ||
(kF16_Linear_DstFormat == kDst);
(kF16_Linear_DstFormat == kDst && kOpaque_SkAlphaType != kAlphaType);
switch (kSrc) {
case kRGBA_8888_Linear_SrcFormat:
if (kLoadAlpha) {