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

Side by Side Diff: gm/imageblur.cpp

Issue 105893003: NEON fast path for box blur (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
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 "gm.h" 8 #include "gm.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
11 11
12 #define WIDTH 500 12 #define WIDTH 500
13 #define HEIGHT 500 13 #define HEIGHT 500
14 14
15 namespace skiagm { 15 namespace skiagm {
16 16
17 class ImageBlurGM : public GM { 17 class ImageBlurGM : public GM {
18 public: 18 public:
19 ImageBlurGM() { 19 ImageBlurGM(SkScalar sigmaX, SkScalar sigmaY, const char* suffix)
20 : fSigmaX(sigmaX), fSigmaY(sigmaY) {
20 this->setBGColor(0xFF000000); 21 this->setBGColor(0xFF000000);
22 fName.printf("imageblur%s", suffix);
21 } 23 }
22 24
23 protected: 25 protected:
24 virtual SkString onShortName() { 26 virtual SkString onShortName() {
25 return SkString("imageblur"); 27 return fName;
26 } 28 }
27 29
28 virtual SkISize onISize() { 30 virtual SkISize onISize() {
29 return make_isize(WIDTH, HEIGHT); 31 return make_isize(WIDTH, HEIGHT);
30 } 32 }
31 33
32 virtual void onDraw(SkCanvas* canvas) { 34 virtual void onDraw(SkCanvas* canvas) {
33 SkPaint paint; 35 SkPaint paint;
34 paint.setImageFilter(new SkBlurImageFilter(24.0f, 0.0f))->unref(); 36 paint.setImageFilter(new SkBlurImageFilter(fSigmaX, fSigmaY))->unref();
35 canvas->saveLayer(NULL, &paint); 37 canvas->saveLayer(NULL, &paint);
36 const char* str = "The quick brown fox jumped over the lazy dog."; 38 const char* str = "The quick brown fox jumped over the lazy dog.";
37 39
38 SkRandom rand; 40 SkRandom rand;
39 SkPaint textPaint; 41 SkPaint textPaint;
40 textPaint.setAntiAlias(true); 42 textPaint.setAntiAlias(true);
41 for (int i = 0; i < 25; ++i) { 43 for (int i = 0; i < 25; ++i) {
42 int x = rand.nextULessThan(WIDTH); 44 int x = rand.nextULessThan(WIDTH);
43 int y = rand.nextULessThan(HEIGHT); 45 int y = rand.nextULessThan(HEIGHT);
44 textPaint.setColor(rand.nextBits(24) | 0xFF000000); 46 textPaint.setColor(rand.nextBits(24) | 0xFF000000);
45 textPaint.setTextSize(rand.nextRangeScalar(0, 300)); 47 textPaint.setTextSize(rand.nextRangeScalar(0, 300));
46 canvas->drawText(str, strlen(str), SkIntToScalar(x), 48 canvas->drawText(str, strlen(str), SkIntToScalar(x),
47 SkIntToScalar(y), textPaint); 49 SkIntToScalar(y), textPaint);
48 } 50 }
49 canvas->restore(); 51 canvas->restore();
50 } 52 }
51 53
52 private: 54 private:
55 SkScalar fSigmaX;
56 SkScalar fSigmaY;
57 SkString fName;
58
53 typedef GM INHERITED; 59 typedef GM INHERITED;
54 }; 60 };
55 61
56 ////////////////////////////////////////////////////////////////////////////// 62 //////////////////////////////////////////////////////////////////////////////
57 63
58 static GM* MyFactory(void*) { return new ImageBlurGM; } 64 static GM* MyFactory1(void*) { return new ImageBlurGM(24.0f, 0.0f, ""); }
59 static GMRegistry reg(MyFactory); 65 static GMRegistry reg1(MyFactory1);
66
67 static GM* MyFactory2(void*) { return new ImageBlurGM(80.0f, 80.0f, "_large"); }
68 static GMRegistry reg2(MyFactory2);
60 69
61 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698