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

Side by Side Diff: src/effects/SkBlurImageFilter.cpp

Issue 57823003: Add SK_PREFETCH and use in SkBlurImageFilter. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/core/SkPostConfig.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The Android Open Source Project 2 * Copyright 2011 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 SkColor* p = src.getAddr32(bounds.fLeft + x, bounds.fTop); 94 SkColor* p = src.getAddr32(bounds.fLeft + x, bounds.fTop);
95 for (int i = 0; i < bottomBorder; ++i) { 95 for (int i = 0; i < bottomBorder; ++i) {
96 sumA += SkGetPackedA32(*p); 96 sumA += SkGetPackedA32(*p);
97 sumR += SkGetPackedR32(*p); 97 sumR += SkGetPackedR32(*p);
98 sumG += SkGetPackedG32(*p); 98 sumG += SkGetPackedG32(*p);
99 sumB += SkGetPackedB32(*p); 99 sumB += SkGetPackedB32(*p);
100 p += srcStride; 100 p += srcStride;
101 } 101 }
102 102
103 const SkColor* sptr = src.getAddr32(bounds.fLeft + x, bounds.fTop); 103 const SkColor* sptr = src.getAddr32(bounds.fLeft + x, bounds.fTop);
104 const SkColor* back = sptr - topOffset * srcStride;
105 const SkColor* front = sptr + (bottomOffset + 1) * srcStride;
104 SkColor* dptr = dst->getAddr32(x, 0); 106 SkColor* dptr = dst->getAddr32(x, 0);
105 for (int y = 0; y < height; ++y) { 107 for (int y = 0; y < height; ++y) {
106 *dptr = SkPackARGB32(sumA / kernelSize, 108 *dptr = SkPackARGB32(sumA / kernelSize,
107 sumR / kernelSize, 109 sumR / kernelSize,
108 sumG / kernelSize, 110 sumG / kernelSize,
109 sumB / kernelSize); 111 sumB / kernelSize);
110 if (y >= topOffset) { 112 if (y >= topOffset) {
111 SkColor l = *(sptr - topOffset * srcStride); 113 SkColor l = *back;
112 sumA -= SkGetPackedA32(l); 114 sumA -= SkGetPackedA32(l);
113 sumR -= SkGetPackedR32(l); 115 sumR -= SkGetPackedR32(l);
114 sumG -= SkGetPackedG32(l); 116 sumG -= SkGetPackedG32(l);
115 sumB -= SkGetPackedB32(l); 117 sumB -= SkGetPackedB32(l);
116 } 118 }
117 if (y + bottomOffset + 1 < height) { 119 if (y + bottomOffset + 1 < height) {
118 SkColor r = *(sptr + (bottomOffset + 1) * srcStride); 120 SkColor r = *front;
119 sumA += SkGetPackedA32(r); 121 sumA += SkGetPackedA32(r);
120 sumR += SkGetPackedR32(r); 122 sumR += SkGetPackedR32(r);
121 sumG += SkGetPackedG32(r); 123 sumG += SkGetPackedG32(r);
122 sumB += SkGetPackedB32(r); 124 sumB += SkGetPackedB32(r);
123 } 125 }
124 sptr += srcStride; 126 front += srcStride;
125 dptr += dstStride; 127 SK_PREFETCH(front); // This step by srcStride seems to be hard to p redict.
Stephen White 2013/11/04 16:24:17 I'm a little leery of prefetch instructions, due t
128 back += srcStride; // back will probably still be cached, so no hi nt needed.
129 dptr += dstStride;
126 } 130 }
127 } 131 }
128 } 132 }
129 133
130 static void getBox3Params(SkScalar s, int *kernelSize, int* kernelSize3, int *lo wOffset, 134 static void getBox3Params(SkScalar s, int *kernelSize, int* kernelSize3, int *lo wOffset,
131 int *highOffset) 135 int *highOffset)
132 { 136 {
133 float pi = SkScalarToFloat(SK_ScalarPI); 137 float pi = SkScalarToFloat(SK_ScalarPI);
134 int d = static_cast<int>(floorf(SkScalarToFloat(s) * 3.0f * sqrtf(2.0f * pi) / 4.0f + 0.5f)); 138 int d = static_cast<int>(floorf(SkScalarToFloat(s) * 3.0f * sqrtf(2.0f * pi) / 4.0f + 0.5f));
135 *kernelSize = d; 139 *kernelSize = d;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 fSigma.width(), 235 fSigma.width(),
232 fSigma.height())); 236 fSigma.height()));
233 offset->fX += rect.fLeft; 237 offset->fX += rect.fLeft;
234 offset->fY += rect.fTop; 238 offset->fY += rect.fTop;
235 return SkImageFilterUtils::WrapTexture(tex, rect.width(), rect.height(), res ult); 239 return SkImageFilterUtils::WrapTexture(tex, rect.width(), rect.height(), res ult);
236 #else 240 #else
237 SkDEBUGFAIL("Should not call in GPU-less build"); 241 SkDEBUGFAIL("Should not call in GPU-less build");
238 return false; 242 return false;
239 #endif 243 #endif
240 } 244 }
OLDNEW
« no previous file with comments | « include/core/SkPostConfig.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698