transform gradient colors without skcms

This use of skcms kind of sticks out as odd now.
We can do all this using plain old SkConvertPixels.

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Id416058717359a413fcae63d2ae5c91040440a87
Reviewed-on: https://skia-review.googlesource.com/c/161583
Auto-Submit: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
Mike Klein 2018-10-11 22:35:53 -04:00 committed by Skia Commit-Bot
parent 1b62fad4b1
commit b27a9cf2f4

View File

@ -9,6 +9,7 @@
#include "Sk4fLinearGradient.h"
#include "SkColorSpacePriv.h"
#include "SkColorSpaceXformer.h"
#include "SkConvertPixels.h"
#include "SkFlattenablePriv.h"
#include "SkFloatBits.h"
#include "SkGradientShaderPriv.h"
@ -21,7 +22,6 @@
#include "SkTwoPointConicalGradient.h"
#include "SkWriteBuffer.h"
#include "../../jumper/SkJumper.h"
#include "../../third_party/skcms/skcms.h"
enum GradientSerializationFlags {
// Bits 29:31 used for various boolean flags
@ -460,29 +460,16 @@ SkGradientShaderBase::AutoXformColors::AutoXformColors(const SkGradientShaderBas
SkColor4fXformer::SkColor4fXformer(const SkColor4f* colors, int colorCount,
SkColorSpace* src, SkColorSpace* dst) {
// Transform all of the colors to destination color space
fColors = colors;
// Treat null destinations as sRGB.
if (!dst) {
dst = sk_srgb_singleton();
}
// Treat null sources as sRGB.
if (!src) {
src = sk_srgb_singleton();
}
if (!SkColorSpace::Equals(src, dst)) {
skcms_ICCProfile srcProfile, dstProfile;
src->toProfile(&srcProfile);
dst->toProfile(&dstProfile);
fStorage.reset(colorCount);
const skcms_PixelFormat rgba_f32 = skcms_PixelFormat_RGBA_ffff;
const skcms_AlphaFormat unpremul = skcms_AlphaFormat_Unpremul;
SkAssertResult(skcms_Transform(colors, rgba_f32, unpremul, &srcProfile,
fStorage.begin(), rgba_f32, unpremul, &dstProfile,
colorCount));
auto info = SkImageInfo::Make(colorCount,1, kRGBA_F32_SkColorType, kUnpremul_SkAlphaType);
SkConvertPixels(info.makeColorSpace(sk_ref_sp(dst)), fStorage.begin(), info.minRowBytes(),
info.makeColorSpace(sk_ref_sp(src)), fColors , info.minRowBytes());
fColors = fStorage.begin();
}
}