Index: src/effects/gradients/SkLinearGradient.cpp |
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp |
index a1abe543c69a89f818d34279569776070b357bd9..9a350b8ff2bce28207236f3c91e31df5a4569d7e 100644 |
--- a/src/effects/gradients/SkLinearGradient.cpp |
+++ b/src/effects/gradients/SkLinearGradient.cpp |
@@ -5,8 +5,12 @@ |
* found in the LICENSE file. |
*/ |
+#include "Sk4fLinearGradient.h" |
#include "SkLinearGradient.h" |
+// define to test the 4f gradient path |
+// #define USE_4fGRADIENTS |
+ |
static const float kInv255Float = 1.0f / 255; |
static inline int repeat_8bits(int x) { |
@@ -43,6 +47,14 @@ static SkMatrix pts_to_unit_matrix(const SkPoint pts[2]) { |
return matrix; |
} |
+static bool use_4f_context(uint32_t flags) { |
+#ifdef USE_4fGRADIENTS |
+ return true; |
+#else |
+ return SkToBool(flags & SkLinearGradient::kForce4fContext_PrivateFlag); |
+#endif |
+} |
+ |
/////////////////////////////////////////////////////////////////////////////// |
SkLinearGradient::SkLinearGradient(const SkPoint pts[2], const Descriptor& desc) |
@@ -70,11 +82,15 @@ void SkLinearGradient::flatten(SkWriteBuffer& buffer) const { |
} |
size_t SkLinearGradient::contextSize() const { |
- return sizeof(LinearGradientContext); |
+ return use_4f_context(fGradFlags) |
+ ? sizeof(LinearGradient4fContext) |
+ : sizeof(LinearGradientContext); |
} |
SkShader::Context* SkLinearGradient::onCreateContext(const ContextRec& rec, void* storage) const { |
- return new (storage) LinearGradientContext(*this, rec); |
+ return use_4f_context(fGradFlags) |
+ ? static_cast<SkShader::Context*>(new (storage) LinearGradient4fContext(*this, rec)) |
+ : static_cast<SkShader::Context*>(new (storage) LinearGradientContext(*this, rec)); |
} |
// This swizzles SkColor into the same component order as SkPMColor, but does not actually |