diff options
author | brianosman <brianosman@google.com> | 2016-09-12 08:50:19 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-12 08:50:19 -0700 |
commit | 5192475bd8cb98e8e0c1192ab5ece7b8595701d6 (patch) | |
tree | 29461e55053726c93c8c612e6fe65dc89fc1a431 /include/gpu | |
parent | 9b0fe3d125f237d9884732a48414fa85fc71b4e3 (diff) |
Two changes:
1. Remove special premul handling from gamut xform code
Alpha is a constant, so the gamut transformation results remain unchanged
(it distributes across the linear matrix multiply).
2. Use SkMatrix44 rather than array of floats
Preserves semantic intention, and makes upcoming code (where we transform
colors on the CPU by that matrix) simpler.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2329553002
Review-Url: https://codereview.chromium.org/2329553002
Diffstat (limited to 'include/gpu')
-rw-r--r-- | include/gpu/GrColorSpaceXform.h | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/include/gpu/GrColorSpaceXform.h b/include/gpu/GrColorSpaceXform.h index c1fb166f47..38b5ccfc08 100644 --- a/include/gpu/GrColorSpaceXform.h +++ b/include/gpu/GrColorSpaceXform.h @@ -8,43 +8,33 @@ #ifndef GrColorSpaceXform_DEFINED #define GrColorSpaceXform_DEFINED -#include "SkImageInfo.h" +#include "SkMatrix44.h" #include "SkRefCnt.h" class SkColorSpace; -class SkMatrix44; /** * Represents a color gamut transformation (as a 4x4 color matrix) */ class GrColorSpaceXform : public SkRefCnt { public: - GrColorSpaceXform(const SkMatrix44& srcToDst, SkAlphaType srcAlphaType); + GrColorSpaceXform(const SkMatrix44& srcToDst); - static sk_sp<GrColorSpaceXform> Make(SkColorSpace* src, SkColorSpace* dst, - SkAlphaType srcAlphaType); + static sk_sp<GrColorSpaceXform> Make(SkColorSpace* src, SkColorSpace* dst); - const float* srcToDst() { return fSrcToDst; } - SkAlphaType alphaType() const { return fSrcAlphaType; } + const SkMatrix44& srcToDst() { return fSrcToDst; } /** * GrGLSLFragmentProcessor::GenKey() must call this and include the returned value in its * computed key. */ static uint32_t XformKey(GrColorSpaceXform* xform) { - if (!xform) { - return 0; - } - // Code generation just depends on whether the alpha type is premul or not - return kPremul_SkAlphaType == xform->fSrcAlphaType ? 1 : 2; + // Code generation changes if there is an xform, but it otherwise constant + return SkToBool(xform) ? 1 : 0; } private: - // We store the column-major form of the srcToDst matrix, for easy uploading to uniforms - float fSrcToDst[16]; - - // Alpha type of the source. If it's premul, we need special handling - SkAlphaType fSrcAlphaType; + SkMatrix44 fSrcToDst; }; #endif |