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

Side by Side Diff: gm/imagefilters.cpp

Issue 1503143002: add gm to exercise large sigmas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix int-float conversion Created 5 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
« 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 2015 Google Inc. 2 * Copyright 2015 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"
10 #include "SkColorMatrixFilter.h"
11 #include "SkImage.h"
9 #include "SkImageFilter.h" 12 #include "SkImageFilter.h"
10 #include "SkColorMatrixFilter.h" 13 #include "SkSurface.h"
11 14
12 /** 15 /**
13 * Test drawing a primitive w/ an imagefilter (in this case, just matrix w/ ide ntity) to see 16 * Test drawing a primitive w/ an imagefilter (in this case, just matrix w/ ide ntity) to see
14 * that we apply the xfermode *after* the image has been created and filtered, and not during 17 * that we apply the xfermode *after* the image has been created and filtered, and not during
15 * the creation step (i.e. before it is filtered). 18 * the creation step (i.e. before it is filtered).
16 * 19 *
17 * see https://bug.skia.org/3741 20 * see https://bug.skia.org/3741
18 */ 21 */
19 static void do_draw(SkCanvas* canvas, SkXfermode::Mode mode, SkImageFilter* imf) { 22 static void do_draw(SkCanvas* canvas, SkXfermode::Mode mode, SkImageFilter* imf) {
20 SkAutoCanvasRestore acr(canvas, true); 23 SkAutoCanvasRestore acr(canvas, true);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 for (size_t i = 0; i < SK_ARRAY_COUNT(modes); ++i) { 58 for (size_t i = 0; i < SK_ARRAY_COUNT(modes); ++i) {
56 canvas->save(); 59 canvas->save();
57 do_draw(canvas, modes[i], nullptr); 60 do_draw(canvas, modes[i], nullptr);
58 canvas->translate(240, 0); 61 canvas->translate(240, 0);
59 do_draw(canvas, modes[i], imf); 62 do_draw(canvas, modes[i], imf);
60 canvas->restore(); 63 canvas->restore();
61 64
62 canvas->translate(0, 240); 65 canvas->translate(0, 240);
63 } 66 }
64 } 67 }
68
69 static SkImage* make_image(SkCanvas* canvas) {
70 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
71 SkAutoTUnref<SkSurface> surface(canvas->newSurface(info));
72 if (!surface) {
73 surface.reset(SkSurface::NewRaster(info));
74 }
75 surface->getCanvas()->drawRect(SkRect::MakeXYWH(25, 25, 50, 50), SkPaint());
76 return surface->newImageSnapshot();
77 }
78
79 // Compare blurs when we're tightly clipped (fast) and not as tightly (slower)
80 //
81 // Expect the two to draw the same (modulo the extra border of pixels when the c lip is larger)
82 //
83 DEF_SIMPLE_GM(fast_slow_blurimagefilter, canvas, 620, 260) {
84 SkAutoTUnref<SkImage> image(make_image(canvas));
85 const SkRect r = SkRect::MakeIWH(image->width(), image->height());
86
87 canvas->translate(10, 10);
88 for (SkScalar sigma = 8; sigma <= 128; sigma *= 2) {
89 SkPaint paint;
90 paint.setImageFilter(SkBlurImageFilter::Create(sigma, sigma))->unref();
91
92 canvas->save();
93 // we outset the clip by 1, to fall out of the fast-case in drawImage
94 // i.e. the clip is larger than the image
95 for (SkScalar outset = 0; outset <= 1; ++outset) {
96 canvas->save();
97 canvas->clipRect(r.makeOutset(outset, outset));
98 canvas->drawImage(image, 0, 0, &paint);
99 canvas->restore();
100 canvas->translate(0, r.height() + 20);
101 }
102 canvas->restore();
103 canvas->translate(r.width() + 20, 0);
104 }
105 }
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