aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-09-16 09:51:12 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-16 09:51:12 -0700
commit43d6651111374b5d1e4ddd9030dcf079b448ec47 (patch)
treecd015928e14895e720154f156aab1e14d3536787 /src/gpu
parenta8370b2c56e42b9e29b4cfbda95d14fdfba7f15e (diff)
Support Float32 output from SkColorSpaceXform
* Adds Float32 support to SkColorSpaceXform * Changes API to allows clients to ask for F32, updates clients to new API * Adds Sk4f_load4 and Sk4f_store4 to SkNx * Make use of new xform in SkGr.cpp BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2339233003 CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot Review-Url: https://codereview.chromium.org/2339233003
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrDrawContext.cpp3
-rw-r--r--src/gpu/SkGr.cpp19
2 files changed, 13 insertions, 9 deletions
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index e9a9619da5..35c53eda0e 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -37,6 +37,7 @@
#include "../private/GrAuditTrail.h"
+#include "SkColorSpaceXform.h"
#include "SkGr.h"
#include "SkLatticeIter.h"
#include "SkMatrixPriv.h"
@@ -96,7 +97,7 @@ GrDrawContext::GrDrawContext(GrContext* context,
if (fColorSpace) {
// sRGB sources are very common (SkColor, etc...), so we cache that gamut transformation
auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
- fColorXformFromSRGB = GrColorSpaceXform::Make(srgbColorSpace.get(), fColorSpace.get());
+ fColorXformFromSRGB = SkColorSpaceXform::New(srgbColorSpace, fColorSpace);
}
SkDEBUGCODE(this->validate();)
}
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index c8839f3f1a..86b1007ba5 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -23,6 +23,7 @@
#include "SkColorFilter.h"
#include "SkConfig8888.h"
#include "SkCanvas.h"
+#include "SkColorSpaceXform.h"
#include "SkData.h"
#include "SkErrorInternals.h"
#include "SkMessageBus.h"
@@ -529,18 +530,20 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
grPaint->setAntiAlias(skPaint.isAntiAlias());
grPaint->setAllowSRGBInputs(dc->isGammaCorrect());
- // Raw translation of the SkPaint color to our 4f format:
- GrColor4f origColor = GrColor4f::FromGrColor(SkColorToUnpremulGrColor(skPaint.getColor()));
+ GrColor4f origColor;
// Linearize, if the color is meant to be in sRGB gamma:
if (dc->isGammaCorrect()) {
- origColor.fRGBA[0] = exact_srgb_to_linear(origColor.fRGBA[0]);
- origColor.fRGBA[1] = exact_srgb_to_linear(origColor.fRGBA[1]);
- origColor.fRGBA[2] = exact_srgb_to_linear(origColor.fRGBA[2]);
+ SkColorSpaceXform* xform = dc->getColorXformFromSRGB();
+ SkASSERT(xform);
- if (dc->getColorXformFromSRGB()) {
- origColor = dc->getColorXformFromSRGB()->apply(origColor);
- }
+ // FIXME (msarett): Support BGRA inputs to SkColorSpaceXform?
+ uint32_t rgba = SkSwizzle_RB(skPaint.getColor());
+ xform->apply(&origColor, &rgba, 1, SkColorSpaceXform::kRGBA_F32_ColorFormat,
+ kUnpremul_SkAlphaType);
+ } else {
+ // Raw translation of the SkPaint color to our 4f format:
+ origColor = GrColor4f::FromGrColor(SkColorToUnpremulGrColor(skPaint.getColor()));
}
// Setup the initial color considering the shader, the SkPaint color, and the presence or not