Avoid recomputing two consecutive identical 1D filters.
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 6 Mar 2014 19:10:44 +0000 (19:10 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 6 Mar 2014 19:10:44 +0000 (19:10 +0000)
If the arguments to the X and Y filter computation are identical,
the results will be identical; copying is much faster than recomputing.

With a change like https://codereview.chromium.org/183763047/ applied
this speeds up BitmapScaleBench on Linux by around 10%.

BUG=skia:2236
R=humper@google.com, tomhudson@google.com

Author: tomhudson@chromium.org

Review URL: https://codereview.chromium.org/188743002

git-svn-id: http://skia.googlecode.com/svn/trunk@13687 2bbb7eff-a529-9590-31e7-b0007b416f81

src/core/SkBitmapScaler.cpp

index a90be05..9e8c5fe 100644 (file)
@@ -89,8 +89,15 @@ SkResizeFilter::SkResizeFilter(SkBitmapScaler::ResizeMethod method,
 
     this->computeFilters(srcFullWidth, destSubset.fLeft, destSubset.width(),
                          scaleX, &fXFilter, convolveProcs);
-    this->computeFilters(srcFullHeight, destSubset.fTop, destSubset.height(),
-                         scaleY, &fYFilter, convolveProcs);
+    if (srcFullWidth == srcFullHeight &&
+        destSubset.fLeft == destSubset.fTop &&
+        destSubset.width() == destSubset.height()&&
+        scaleX == scaleY) {
+        fYFilter = fXFilter;
+    } else {
+        this->computeFilters(srcFullHeight, destSubset.fTop, destSubset.height(),
+                          scaleY, &fYFilter, convolveProcs);
+    }
 }
 
 // TODO(egouriou): Take advantage of periods in the convolution.