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

Unified Diff: src/core/SkBitmapFilter.cpp

Issue 759603002: Optimize highQualityFilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add const Created 6 years, 1 month 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 | « no previous file | src/opts/SkBitmapFilter_opts_SSE2.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmapFilter.cpp
diff --git a/src/core/SkBitmapFilter.cpp b/src/core/SkBitmapFilter.cpp
index 20a05142506c1890e2c4eea964299def656da068..fce4c1d5fbc2f1c9b913e89515bea1481c33e013 100644
--- a/src/core/SkBitmapFilter.cpp
+++ b/src/core/SkBitmapFilter.cpp
@@ -29,6 +29,7 @@ void highQualityFilter(ColorPacker pack, const SkBitmapProcState& s, int x, int
const int maxX = s.fBitmap->width();
const int maxY = s.fBitmap->height();
SkAutoTMalloc<SkScalar> xWeights(maxX);
+ const SkBitmapFilter* filter = s.getBitmapFilter();
while (count-- > 0) {
SkPoint srcPt;
@@ -40,30 +41,33 @@ void highQualityFilter(ColorPacker pack, const SkBitmapProcState& s, int x, int
SkScalar weight = 0;
SkScalar fr = 0, fg = 0, fb = 0, fa = 0;
- int y0 = SkClampMax(SkScalarCeilToInt(srcPt.fY-s.getBitmapFilter()->width()), maxY);
- int y1 = SkClampMax(SkScalarFloorToInt(srcPt.fY+s.getBitmapFilter()->width()+1), maxY);
- int x0 = SkClampMax(SkScalarCeilToInt(srcPt.fX-s.getBitmapFilter()->width()), maxX);
- int x1 = SkClampMax(SkScalarFloorToInt(srcPt.fX+s.getBitmapFilter()->width())+1, maxX);
+ int y0 = SkClampMax(SkScalarCeilToInt(srcPt.fY - filter->width()), maxY);
+ int y1 = SkClampMax(SkScalarFloorToInt(srcPt.fY + filter->width() + 1), maxY);
+ int x0 = SkClampMax(SkScalarCeilToInt(srcPt.fX - filter->width()), maxX);
+ int x1 = SkClampMax(SkScalarFloorToInt(srcPt.fX + filter->width()) + 1, maxX);
for (int srcX = x0; srcX < x1 ; srcX++) {
// Looking these up once instead of each loop is a ~15% speedup.
- xWeights[srcX - x0] = s.getBitmapFilter()->lookupScalar((srcPt.fX - srcX));
+ xWeights[srcX - x0] = filter->lookupScalar((srcPt.fX - srcX));
}
for (int srcY = y0; srcY < y1; srcY++) {
- SkScalar yWeight = s.getBitmapFilter()->lookupScalar((srcPt.fY - srcY));
+ SkScalar yWeight = filter->lookupScalar((srcPt.fY - srcY));
for (int srcX = x0; srcX < x1 ; srcX++) {
SkScalar xWeight = xWeights[srcX - x0];
SkScalar combined_weight = SkScalarMul(xWeight, yWeight);
+ weight += combined_weight;
SkPMColor c = *s.fBitmap->getAddr32(srcX, srcY);
+ if (!c) {
+ continue;
+ }
fr += combined_weight * SkGetPackedR32(c);
reed1 2014/11/25 14:34:33 boy oh boy, this seems to beg for Sk4f ...
mtklein 2014/11/25 15:02:22 Yep, I will certainly try this out.
fg += combined_weight * SkGetPackedG32(c);
fb += combined_weight * SkGetPackedB32(c);
fa += combined_weight * SkGetPackedA32(c);
- weight += combined_weight;
}
}
« no previous file with comments | « no previous file | src/opts/SkBitmapFilter_opts_SSE2.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698