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

Side by Side Diff: gm/spritebitmap.cpp

Issue 1401053003: change SkImage_Gpu to handle all filters (w/ and w/o gpu support (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/image/SkImage_Gpu.cpp » ('j') | 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 2013 Google Inc. 2 * Copyright 2013 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 "SkBlurImageFilter.h" 10 #include "SkBlurImageFilter.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 canvas->drawImage(image, x, y, nullptr); 134 canvas->drawImage(image, x, y, nullptr);
135 } 135 }
136 136
137 typedef SkImageFilter* (*ImageFilterFactory)(); 137 typedef SkImageFilter* (*ImageFilterFactory)();
138 138
139 // +[]{...} did not work on windows (VS) 139 // +[]{...} did not work on windows (VS)
140 // (ImageFilterFactory)[]{...} did not work on linux (gcc) 140 // (ImageFilterFactory)[]{...} did not work on linux (gcc)
141 // hence this cast function 141 // hence this cast function
142 template <typename T> ImageFilterFactory IFCCast(T arg) { return arg; } 142 template <typename T> ImageFilterFactory IFCCast(T arg) { return arg; }
143 143
144 // We expect that applying the filter will keep us in the same domain (raster or gpu)
145 static void check_same_domain(SkImage* a, SkImage* b) {
146 SkASSERT(a->isTextureBacked() == b->isTextureBacked());
147 }
148
144 /** 149 /**
145 * Compare output of drawSprite and drawBitmap (esp. clipping and imagefilters) 150 * Compare output of drawSprite and drawBitmap (esp. clipping and imagefilters)
146 */ 151 */
147 class ApplyFilterGM : public skiagm::GM { 152 class ApplyFilterGM : public skiagm::GM {
148 public: 153 public:
149 ApplyFilterGM() {} 154 ApplyFilterGM() {}
150 155
151 protected: 156 protected:
152 SkString onShortName() override { 157 SkString onShortName() override {
153 return SkString("apply-filter"); 158 return SkString("apply-filter");
(...skipping 19 matching lines...) Expand all
173 178
174 const SkScalar spacer = image0->width() * 3.0f / 2; 179 const SkScalar spacer = image0->width() * 3.0f / 2;
175 180
176 for (auto&& factory : factories) { 181 for (auto&& factory : factories) {
177 SkAutoTUnref<SkImageFilter> filter(factory()); 182 SkAutoTUnref<SkImageFilter> filter(factory());
178 183
179 SkIPoint offset1, offset2; 184 SkIPoint offset1, offset2;
180 SkAutoTUnref<SkImage> image1(image0->applyFilter(filter, &offset1, t rue)); 185 SkAutoTUnref<SkImage> image1(image0->applyFilter(filter, &offset1, t rue));
181 SkAutoTUnref<SkImage> image2(image0->applyFilter(filter, &offset2, f alse)); 186 SkAutoTUnref<SkImage> image2(image0->applyFilter(filter, &offset2, f alse));
182 187
188 check_same_domain(image0, image1);
189 check_same_domain(image0, image2);
190
183 canvas->save(); 191 canvas->save();
184 canvas->translate(30, 30); 192 canvas->translate(30, 30);
185 show_image(canvas, image0, SkIPoint::Make(0, 0)); // original 193 show_image(canvas, image0, SkIPoint::Make(0, 0)); // original
186 canvas->translate(spacer, 0); 194 canvas->translate(spacer, 0);
187 show_image(canvas, image1, offset1); // snug 195 show_image(canvas, image1, offset1); // snug
188 canvas->translate(spacer, 0); 196 canvas->translate(spacer, 0);
189 show_image(canvas, image2, offset2); // not snug 197 show_image(canvas, image2, offset2); // not snug
190 198
191 // Try drawing the original w/ the filter, to see that it "draws" th e same as 199 // Try drawing the original w/ the filter, to see that it "draws" th e same as
192 // when we have manually applied the filter (above). 200 // when we have manually applied the filter (above).
(...skipping 15 matching lines...) Expand all
208 216
209 canvas->translate(0, spacer); 217 canvas->translate(0, spacer);
210 } 218 }
211 } 219 }
212 220
213 private: 221 private:
214 typedef GM INHERITED; 222 typedef GM INHERITED;
215 }; 223 };
216 DEF_GM( return new ApplyFilterGM; ) 224 DEF_GM( return new ApplyFilterGM; )
217 225
OLDNEW
« no previous file with comments | « no previous file | src/image/SkImage_Gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698