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

Side by Side Diff: gm/blurs.cpp

Issue 728863002: add gm for 2-rects and blur (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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
2 /* 1 /*
3 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
4 * 3 *
5 * 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
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
11 11
12 namespace skiagm { 12 class BlursGM : public skiagm::GM {
13
14 class BlursGM : public GM {
15 public: 13 public:
16 BlursGM() { 14 BlursGM() {
17 this->setBGColor(0xFFDDDDDD); 15 this->setBGColor(0xFFDDDDDD);
18 } 16 }
19 17
20 protected: 18 protected:
21 virtual uint32_t onGetFlags() const SK_OVERRIDE { 19 virtual uint32_t onGetFlags() const SK_OVERRIDE {
22 return kSkipTiled_Flag; 20 return kSkipTiled_Flag;
23 } 21 }
24 22
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 y -= SkIntToScalar(2); 83 y -= SkIntToScalar(2);
86 canvas->drawText("Hamburgefons Style", 18, x, y, paint); 84 canvas->drawText("Hamburgefons Style", 18, x, y, paint);
87 } 85 }
88 canvas->restore(); 86 canvas->restore();
89 flags = SkBlurMaskFilter::kHighQuality_BlurFlag; 87 flags = SkBlurMaskFilter::kHighQuality_BlurFlag;
90 canvas->translate(SkIntToScalar(350), SkIntToScalar(0)); 88 canvas->translate(SkIntToScalar(350), SkIntToScalar(0));
91 } 89 }
92 } 90 }
93 91
94 private: 92 private:
95 typedef GM INHERITED; 93 typedef skiagm::GM INHERITED;
96 }; 94 };
95 DEF_GM( return new BlursGM; )
97 96
98 ////////////////////////////////////////////////////////////////////////////// 97 //////////////////////////////////////////////////////////////////////////////// //////////////
99 98
100 static GM* MyFactory(void*) { return new BlursGM; } 99 // exercise a special-case of blurs, which is two nested rects. These are drawn specially,
101 static GMRegistry reg(MyFactory); 100 // and possibly cached.
101 //
102 // in particular, we want to notice that the 2nd rect draws slightly differently , since it
103 // is translated a fractional amount.
104 //
105 class Blur2RectsGM : public skiagm::GM {
106 public:
107 SkString onShortName() SK_OVERRIDE {
108 return SkString("blur2rects");
109 }
102 110
103 } 111 SkISize onISize() SK_OVERRIDE {
112 return SkISize::Make(700, 500);
113 }
114
115 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
116 SkPaint paint;
117
118 paint.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
119 2.3f))->unref();
120
121 SkRect outer = SkRect::MakeXYWH(10.125f, 10.125f, 100, 100);
122 SkRect inner = SkRect::MakeXYWH(20, 20, 80, 80);
123 SkPath path;
124 path.addRect(outer, SkPath::kCW_Direction);
125 path.addRect(inner, SkPath::kCCW_Direction);
126
127 canvas->drawPath(path, paint);
128 // important to translate by a factional amount (.25) to exercise a diff erent "phase"
129 // of the same path w.r.t. the pixel grid
130 canvas->translate(SkScalarRoundToScalar(path.getBounds().width()) + 14 + 0.25f, 0);
131 canvas->drawPath(path, paint);
132 }
133 };
134 DEF_GM( return new Blur2RectsGM; )
OLDNEW
« 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