diff options
author | fmalita <fmalita@chromium.org> | 2016-02-23 13:26:28 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-23 13:26:28 -0800 |
commit | 55430a620762e882c2b3018c57f9a7d51cf16071 (patch) | |
tree | 09ffdf9f327bbd1faf0237a98ab3203243a01440 /src/effects/gradients | |
parent | ccb74b824a16d0009f7f9ebcf2a03fb53451af9a (diff) |
Update 4f linear gradient selection heuristic
Use the 4f context when
* dest type is 4f
* there's no perpective
Keeping the define and testing flag overrides for now.
R=reed@google.com,herb@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1725793003
Review URL: https://codereview.chromium.org/1725793003
Diffstat (limited to 'src/effects/gradients')
-rw-r--r-- | src/effects/gradients/SkLinearGradient.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp index 1fbd96e40e..cc8875cf8e 100644 --- a/src/effects/gradients/SkLinearGradient.cpp +++ b/src/effects/gradients/SkLinearGradient.cpp @@ -9,7 +9,7 @@ #include "SkLinearGradient.h" // define to test the 4f gradient path -// #define USE_4fGRADIENTS +// #define FORCE_4F_CONTEXT static const float kInv255Float = 1.0f / 255; @@ -47,11 +47,18 @@ static SkMatrix pts_to_unit_matrix(const SkPoint pts[2]) { return matrix; } -static bool use_4f_context(uint32_t flags) { -#ifdef USE_4fGRADIENTS +static bool use_4f_context(const SkShader::ContextRec& rec, uint32_t flags) { +#ifdef FORCE_4F_CONTEXT return true; #else - return SkToBool(flags & SkLinearGradient::kForce4fContext_PrivateFlag); + // Perspective not supported in 4f yet. + if (rec.fMatrix->hasPerspective() + || (rec.fLocalMatrix && rec.fLocalMatrix->hasPerspective())) { + return false; + } + + return rec.fPreferredDstType == SkShader::ContextRec::kPM4f_DstType + || SkToBool(flags & SkLinearGradient::kForce4fContext_PrivateFlag); #endif } @@ -81,14 +88,14 @@ void SkLinearGradient::flatten(SkWriteBuffer& buffer) const { buffer.writePoint(fEnd); } -size_t SkLinearGradient::contextSize(const ContextRec&) const { - return use_4f_context(fGradFlags) +size_t SkLinearGradient::contextSize(const ContextRec& rec) const { + return use_4f_context(rec, fGradFlags) ? sizeof(LinearGradient4fContext) : sizeof(LinearGradientContext); } SkShader::Context* SkLinearGradient::onCreateContext(const ContextRec& rec, void* storage) const { - return use_4f_context(fGradFlags) + return use_4f_context(rec, fGradFlags) ? static_cast<SkShader::Context*>(new (storage) LinearGradient4fContext(*this, rec)) : static_cast<SkShader::Context*>(new (storage) LinearGradientContext(*this, rec)); } |