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

Side by Side Diff: gm/imagefilterscropped.cpp

Issue 20315002: Transpose the samples in imagefilterscropped, and add a 1x1 blur. The latter (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« 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 /* 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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColorFilter.h" 10 #include "SkColorFilter.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 class ImageFiltersCroppedGM : public skiagm::GM { 100 class ImageFiltersCroppedGM : public skiagm::GM {
101 public: 101 public:
102 ImageFiltersCroppedGM () {} 102 ImageFiltersCroppedGM () {}
103 103
104 protected: 104 protected:
105 105
106 virtual SkString onShortName() { 106 virtual SkString onShortName() {
107 return SkString("imagefilterscropped"); 107 return SkString("imagefilterscropped");
108 } 108 }
109 109
110 virtual SkISize onISize() { return SkISize::Make(700, 460); } 110 virtual SkISize onISize() { return SkISize::Make(400, 640); }
111 111
112 void draw_frame(SkCanvas* canvas, const SkRect& r) { 112 void draw_frame(SkCanvas* canvas, const SkRect& r) {
113 SkPaint paint; 113 SkPaint paint;
114 paint.setStyle(SkPaint::kStroke_Style); 114 paint.setStyle(SkPaint::kStroke_Style);
115 paint.setColor(SK_ColorRED); 115 paint.setColor(SK_ColorRED);
116 canvas->drawRect(r, paint); 116 canvas->drawRect(r, paint);
117 } 117 }
118 118
119 virtual uint32_t onGetFlags() const { 119 virtual uint32_t onGetFlags() const {
120 // Because of the use of drawSprite, this test is excluded 120 // Because of the use of drawSprite, this test is excluded
121 // from scaled replay tests because drawSprite ignores the 121 // from scaled replay tests because drawSprite ignores the
122 // reciprocal scale that is applied at record time, which is 122 // reciprocal scale that is applied at record time, which is
123 // the intended behavior of drawSprite. 123 // the intended behavior of drawSprite.
124 return kSkipScaledReplay_Flag; 124 return kSkipScaledReplay_Flag;
125 } 125 }
126 126
127 virtual void onDraw(SkCanvas* canvas) { 127 virtual void onDraw(SkCanvas* canvas) {
128 void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = { 128 void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = {
129 draw_sprite, draw_bitmap, draw_path, draw_paint, draw_text 129 draw_sprite, draw_bitmap, draw_path, draw_paint, draw_text
130 }; 130 };
131 131
132 SkColorFilter* cf = SkColorFilter::CreateModeFilter(SK_ColorRED, 132 SkColorFilter* cf = SkColorFilter::CreateModeFilter(SK_ColorRED,
133 SkXfermode::kSrcIn_Mode); 133 SkXfermode::kSrcIn_Mode);
134 SkIRect cropRect = SkIRect::MakeXYWH(10, 10, 44, 44); 134 SkIRect cropRect = SkIRect::MakeXYWH(10, 10, 44, 44);
135 SkIRect bogusRect = SkIRect::MakeXYWH(-100, -100, 10, 10); 135 SkIRect bogusRect = SkIRect::MakeXYWH(-100, -100, 10, 10);
136 136
137 SkImageFilter* filters[] = { 137 SkImageFilter* filters[] = {
138 NULL, 138 NULL,
139 SkColorFilterImageFilter::Create(cf, NULL, &cropRect), 139 SkColorFilterImageFilter::Create(cf, NULL, &cropRect),
140 new SkBlurImageFilter(1.0f, 1.0f, NULL, &cropRect),
140 new SkBlurImageFilter(8.0f, 0.0f, NULL, &cropRect), 141 new SkBlurImageFilter(8.0f, 0.0f, NULL, &cropRect),
141 new SkBlurImageFilter(0.0f, 8.0f, NULL, &cropRect), 142 new SkBlurImageFilter(0.0f, 8.0f, NULL, &cropRect),
142 new SkBlurImageFilter(8.0f, 8.0f, NULL, &cropRect), 143 new SkBlurImageFilter(8.0f, 8.0f, NULL, &cropRect),
143 new SkBlurImageFilter(8.0f, 8.0f, NULL, &bogusRect), 144 new SkBlurImageFilter(8.0f, 8.0f, NULL, &bogusRect),
144 SkColorFilterImageFilter::Create(cf, NULL, &bogusRect), 145 SkColorFilterImageFilter::Create(cf, NULL, &bogusRect),
145 }; 146 };
146 cf->unref(); 147 cf->unref();
147 148
148 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); 149 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64));
149 SkScalar MARGIN = SkIntToScalar(16); 150 SkScalar MARGIN = SkIntToScalar(16);
150 SkScalar DX = r.width() + MARGIN; 151 SkScalar DX = r.width() + MARGIN;
151 SkScalar DY = r.height() + MARGIN; 152 SkScalar DY = r.height() + MARGIN;
152 153
153 canvas->translate(MARGIN, MARGIN); 154 canvas->translate(MARGIN, MARGIN);
154 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { 155 for (size_t j = 0; j < SK_ARRAY_COUNT(drawProc); ++j) {
155 canvas->save(); 156 canvas->save();
156 for (size_t j = 0; j < SK_ARRAY_COUNT(drawProc); ++j) { 157 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
157 drawProc[j](canvas, r, filters[i]); 158 drawProc[j](canvas, r, filters[i]);
158 canvas->translate(0, DY); 159 canvas->translate(0, DY);
159 } 160 }
160 canvas->restore(); 161 canvas->restore();
161 canvas->translate(DX, 0); 162 canvas->translate(DX, 0);
162 } 163 }
163 164
164 for(size_t j = 0; j < SK_ARRAY_COUNT(filters); ++j) { 165 for(size_t j = 0; j < SK_ARRAY_COUNT(filters); ++j) {
165 SkSafeUnref(filters[j]); 166 SkSafeUnref(filters[j]);
166 } 167 }
167 } 168 }
168 169
169 private: 170 private:
170 typedef GM INHERITED; 171 typedef GM INHERITED;
171 }; 172 };
172 173
173 /////////////////////////////////////////////////////////////////////////////// 174 ///////////////////////////////////////////////////////////////////////////////
174 175
175 static skiagm::GM* MyFactory(void*) { return new ImageFiltersCroppedGM; } 176 static skiagm::GM* MyFactory(void*) { return new ImageFiltersCroppedGM; }
176 static skiagm::GMRegistry reg(MyFactory); 177 static skiagm::GMRegistry reg(MyFactory);
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