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

Unified Diff: src/core/SkConvolver.cpp

Issue 184323003: Manually set fFilterValues in SkConvolutionFilter1D. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkConvolver.cpp
===================================================================
--- src/core/SkConvolver.cpp (revision 13679)
+++ src/core/SkConvolver.cpp (working copy)
@@ -283,6 +283,7 @@
firstNonZero++;
}
+ int initialOffset = fFilterValues.count();
if (firstNonZero < filterLength) {
// Here we have at least one non-zero factor.
int lastNonZero = filterLength - 1;
@@ -294,9 +295,13 @@
filterLength = lastNonZero + 1 - firstNonZero;
SkASSERT(filterLength > 0);
+ // Calling fFilterValues.reset(), or push_back() in a loop, are expensive.
+ // Over-allocate so we can do it once instead of iteratively.
+ if (!initialOffset) fFilterValues.resize_back(filterLength * filterLength);
for (int i = firstNonZero; i <= lastNonZero; i++) {
- fFilterValues.push_back(filterValues[i]);
+ fFilterValues[initialOffset + i - firstNonZero] = filterValues[i];
}
+
} else {
// Here all the factors were zeroes.
filterLength = 0;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698