Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Unified Diff: src/effects/gradients/SkLinearGradient.cpp

Issue 1688543002: Initial linear gradient 4f impl (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/gradients/SkLinearGradient.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/effects/gradients/SkLinearGradient.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698