aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-04-23 15:19:07 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-23 15:19:07 -0700
commitbb34a8ac59850f128d9602e629a7475e3ad1a9d2 (patch)
tree007da1842b9b14bd7aff8dc73e0531fee9852a7d /src
parent36736a2dae94947e075ac9503d5de7799772a5f7 (diff)
allow imagefilter to manage CTM decomposition
Diffstat (limited to 'src')
-rw-r--r--src/core/SkCanvas.cpp3
-rw-r--r--src/core/SkImageFilter.cpp18
-rw-r--r--src/effects/SkColorFilterImageFilter.cpp6
3 files changed, 25 insertions, 2 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 89c3c9e006..f8731e9ad2 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1217,8 +1217,7 @@ void SkCanvas::internalSaveLayer(const SaveLayerRec& rec, SaveLayerStrategy stra
* Perhaps in the future we could augment #5 to apply REMAINDER as part of the draw (no longer
* a sprite operation) to avoid the extra buffer/overhead of MatrixImageFilter.
*/
- if (imageFilter &&
- !stashedMatrix.isScaleTranslate() &&
+ if (imageFilter && !stashedMatrix.isScaleTranslate() && !imageFilter->canHandleAffine() &&
stashedMatrix.decomposeScale(&scale, &remainder))
{
// We will restore the matrix (which we are overwriting here) in restore via fStashedMatrix
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 4128ba6cc2..6c73be29b5 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -330,6 +330,24 @@ bool SkImageFilter::asAColorFilter(SkColorFilter** filterPtr) const {
return true;
}
+bool SkImageFilter::onCanHandleAffine() const {
+ bool hasInputs = false;
+
+ const int count = this->countInputs();
+ for (int i = 0; i < count; ++i) {
+ SkImageFilter* input = this->getInput(i);
+ if (input) {
+ if (!input->canHandleAffine()) {
+ return false;
+ }
+ hasInputs = true;
+ }
+ }
+ // We return true iff we had 1 or more inputs, and all of them can handle affine.
+ // If we have no inputs, or 1 or more of them do not handle affine, then we return false.
+ return hasInputs;
+}
+
bool SkImageFilter::applyCropRect(const Context& ctx, const SkIRect& srcBounds,
SkIRect* dstBounds) const {
SkIRect temp = this->onFilterNodeBounds(srcBounds, ctx.ctm(), kForward_MapDirection);
diff --git a/src/effects/SkColorFilterImageFilter.cpp b/src/effects/SkColorFilterImageFilter.cpp
index 8d412cc2f5..7a2f4cc2ab 100644
--- a/src/effects/SkColorFilterImageFilter.cpp
+++ b/src/effects/SkColorFilterImageFilter.cpp
@@ -126,6 +126,12 @@ bool SkColorFilterImageFilter::onIsColorFilterNode(SkColorFilter** filter) const
return false;
}
+bool SkColorFilterImageFilter::onCanHandleAffine() const {
+ SkASSERT(1 == this->countInputs());
+ SkImageFilter* input = this->getInput(0);
+ return !input || input->canHandleAffine();
+}
+
bool SkColorFilterImageFilter::affectsTransparentBlack() const {
return fColorFilter->affectsTransparentBlack();
}