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

Unified Diff: src/opts/SkBlurImageFilter_opts.h

Issue 1426583004: SkBlurImageFilter_opt.h: break conditions into separate loops. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update to ToT Created 5 years, 2 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/opts/SkBlurImageFilter_opts.h
diff --git a/src/opts/SkBlurImageFilter_opts.h b/src/opts/SkBlurImageFilter_opts.h
index 5633e2ee6fa88d8eceeb07ed729740e2661efe4f..94d734627ba64848601ee3e3aa88d7c338a7e54a 100644
--- a/src/opts/SkBlurImageFilter_opts.h
+++ b/src/opts/SkBlurImageFilter_opts.h
@@ -174,10 +174,17 @@ static inline uint16x4_t expand(SkPMColor p) {
#endif
+#define PREFETCH_RPTR \
+ if (srcDirection == BlurDirection::kY) { \
+ SK_PREFETCH(rptr); \
+ }
+
template<BlurDirection srcDirection, BlurDirection dstDirection>
static void box_blur(const SkPMColor* src, int srcStride, SkPMColor* dst, int kernelSize,
int leftOffset, int rightOffset, int width, int height) {
- int rightBorder = SkMin32(rightOffset + 1, width);
+ int incrementStart = SkMax32(-rightOffset - 1, -width);
+ int incrementEnd = SkMax32(width - rightOffset - 1, 0);
+ int decrementStart = SkMin32(leftOffset, width);
int srcStrideX = srcDirection == BlurDirection::kX ? 1 : srcStride;
int dstStrideX = dstDirection == BlurDirection::kX ? 1 : height;
int srcStrideY = srcDirection == BlurDirection::kX ? srcStride : 1;
@@ -189,29 +196,40 @@ static void box_blur(const SkPMColor* src, int srcStride, SkPMColor* dst, int ke
for (int y = 0; y < height; ++y) {
INIT_SUMS
- const SkPMColor* p = src;
- for (int i = 0; i < rightBorder; ++i) {
- INCREMENT_SUMS(*p);
- p += srcStrideX;
- }
-
- const SkPMColor* sptr = src;
+ const SkPMColor* lptr = src;
+ const SkPMColor* rptr = src;
SkColor* dptr = dst;
- for (int x = 0; x < width; ++x) {
+ int x;
+ for (x = incrementStart; x < 0; ++x) {
+ INCREMENT_SUMS(*rptr);
+ rptr += srcStrideX;
+ PREFETCH_RPTR
+ }
+ for (; x < decrementStart && x < incrementEnd; ++x) {
+ STORE_SUMS
+ dptr += dstStrideX;
+ INCREMENT_SUMS(*rptr);
+ rptr += srcStrideX;
+ PREFETCH_RPTR
+ }
+ for (x = decrementStart; x < incrementEnd; ++x) {
+ STORE_SUMS
+ dptr += dstStrideX;
+ INCREMENT_SUMS(*rptr);
+ rptr += srcStrideX;
+ PREFETCH_RPTR
+ DECREMENT_SUMS(*lptr);
+ lptr += srcStrideX;
+ }
+ for (x = incrementEnd; x < decrementStart; ++x) {
+ STORE_SUMS
+ dptr += dstStrideX;
+ }
+ for (; x < width; ++x) {
STORE_SUMS
- if (x >= leftOffset) {
- SkColor l = *(sptr - leftOffset * srcStrideX);
- DECREMENT_SUMS(l);
- }
- if (x + rightOffset + 1 < width) {
- SkColor r = *(sptr + (rightOffset + 1) * srcStrideX);
- INCREMENT_SUMS(r);
- }
- sptr += srcStrideX;
- if (srcDirection == BlurDirection::kY) {
- SK_PREFETCH(sptr + (rightOffset + 1) * srcStrideX);
- }
dptr += dstStrideX;
+ DECREMENT_SUMS(*lptr);
+ lptr += srcStrideX;
}
src += srcStrideY;
dst += dstStrideY;
« 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