aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar brianosman <brianosman@google.com>2016-09-07 08:09:10 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-07 08:09:10 -0700
commit77320dbabcddf05c0a1489eaf1f496729dc8de0e (patch)
tree6dce3ee85d2206685279217db47e66dd47839e43 /include
parentd2e39dbc6a68a6cc2a480d0c8082eb204f6b6e77 (diff)
Add color gamut xform helpers to GrGLSLShaderBuilder
New helper functions inject the necessary shader function. Texture lookup functions can now insert the gamut xform at the appropriate place, too. As written, could be used to transform non-texture colors (e.g. vertex colors) as well. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2180803005 Review-Url: https://codereview.chromium.org/2180803005
Diffstat (limited to 'include')
-rw-r--r--include/gpu/GrColorSpaceXform.h22
1 files changed, 20 insertions, 2 deletions
diff --git a/include/gpu/GrColorSpaceXform.h b/include/gpu/GrColorSpaceXform.h
index 177230c87c..c1fb166f47 100644
--- a/include/gpu/GrColorSpaceXform.h
+++ b/include/gpu/GrColorSpaceXform.h
@@ -8,6 +8,7 @@
#ifndef GrColorSpaceXform_DEFINED
#define GrColorSpaceXform_DEFINED
+#include "SkImageInfo.h"
#include "SkRefCnt.h"
class SkColorSpace;
@@ -18,15 +19,32 @@ class SkMatrix44;
*/
class GrColorSpaceXform : public SkRefCnt {
public:
- GrColorSpaceXform(const SkMatrix44& srcToDst);
+ GrColorSpaceXform(const SkMatrix44& srcToDst, SkAlphaType srcAlphaType);
- static sk_sp<GrColorSpaceXform> Make(SkColorSpace* src, SkColorSpace* dst);
+ static sk_sp<GrColorSpaceXform> Make(SkColorSpace* src, SkColorSpace* dst,
+ SkAlphaType srcAlphaType);
const float* srcToDst() { return fSrcToDst; }
+ SkAlphaType alphaType() const { return fSrcAlphaType; }
+
+ /**
+ * 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;
+ }
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;
};
#endif