aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPM4fPriv.h
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2016-11-11 12:51:36 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-12 15:04:47 +0000
commit744908e5e81f81f34288a1b5547aa4ea990ad13d (patch)
treee61d5ca45844cab022a844eec4e764585c4c075c /src/core/SkPM4fPriv.h
parent83b5b21714fc4eac4a1cb88efe6b6777a40303e1 (diff)
Fix SkModeColorFilter in 565
It has been incorrectly interpreting its SkColor as sRGB all the time. Now, we plumb through the destintation color space and some scratch space, letting it decide how to interpret its SkColor later when it knows about the dst color space. The scratch space is blitter scoped, which lets this be thread safe (this is much like SkShader::Context). This only corrects the gamma transformation for now. I've kept my previous TODO about gamut transformation. Everything assumes sRGB gamut for now. Shaders will get the same treatement in this pipeline. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4725 Change-Id: I55b0c7d5db9ad8d7dcdd6295c9dac61d10aeaed4 Reviewed-on: https://skia-review.googlesource.com/4725 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core/SkPM4fPriv.h')
-rw-r--r--src/core/SkPM4fPriv.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/SkPM4fPriv.h b/src/core/SkPM4fPriv.h
index 89a0caeb70..f70c5c5a53 100644
--- a/src/core/SkPM4fPriv.h
+++ b/src/core/SkPM4fPriv.h
@@ -9,6 +9,7 @@
#define SkPM4fPriv_DEFINED
#include "SkColorPriv.h"
+#include "SkColorSpace.h"
#include "SkPM4f.h"
#include "SkSRGB.h"
@@ -71,4 +72,17 @@ static inline float exact_srgb_to_linear(float srgb) {
return linear;
}
+static inline SkPM4f SkPM4f_from_SkColor(SkColor color, SkColorSpace* dst) {
+ SkColor4f color4f;
+ if (dst) {
+ // sRGB gamma, sRGB gamut.
+ color4f = SkColor4f::FromColor(color);
+ // TODO: gamut transform if needed
+ } else {
+ // Linear gamma, dst gamut.
+ swizzle_rb(SkNx_cast<float>(Sk4b::Load(&color)) * (1/255.0f)).store(&color4f);
+ }
+ return color4f.premul();
+}
+
#endif