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

Side by Side Diff: gm/imagefilters.cpp

Issue 1085333003: adjust GM to have a final opaque bg, to make it easier to triage (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 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 | 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 "SkImageFilter.h" 9 #include "SkImageFilter.h"
10 #include "SkColorMatrixFilter.h" 10 #include "SkColorMatrixFilter.h"
11 11
12 /** 12 /**
13 * Test drawing a primitive w/ an imagefilter (in this case, just matrix w/ ide ntity) to see 13 * 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 14 * 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). 15 * the creation step (i.e. before it is filtered).
16 * 16 *
17 * see skbug.com/3741 17 * see skbug.com/3741
18 */ 18 */
19 class ImageFilterXfermodeTestGM : public skiagm::GM { 19 class ImageFilterXfermodeTestGM : public skiagm::GM {
20 protected: 20 protected:
21 SkString onShortName() override { 21 SkString onShortName() override {
22 return SkString("imagefilters_xfermodes"); 22 return SkString("imagefilters_xfermodes");
23 } 23 }
24 24
25 SkISize onISize() override { return SkISize::Make(480, 480); } 25 SkISize onISize() override { return SkISize::Make(480, 480); }
26 26
27 void doDraw(SkCanvas* canvas, SkXfermode::Mode mode, SkImageFilter* imf) { 27 void doDraw(SkCanvas* canvas, SkXfermode::Mode mode, SkImageFilter* imf) {
28 SkAutoCanvasRestore acr(canvas, true);
29 canvas->clipRect(SkRect::MakeWH(220, 220));
30
31 // want to force a layer, so modes like DstIn can combine meaningfully, but the final
32 // image can still be shown against our default (opaque) background. non -opaque GMs
33 // are a lot more trouble to compare/triage.
34 canvas->saveLayer(NULL, NULL);
35 canvas->drawColor(SK_ColorGREEN);
36
28 SkPaint paint; 37 SkPaint paint;
29 paint.setAntiAlias(true); 38 paint.setAntiAlias(true);
30 39
31 SkRect r0 = SkRect::MakeXYWH(10, 60, 200, 100); 40 SkRect r0 = SkRect::MakeXYWH(10, 60, 200, 100);
32 SkRect r1 = SkRect::MakeXYWH(60, 10, 100, 200); 41 SkRect r1 = SkRect::MakeXYWH(60, 10, 100, 200);
33 42
34 paint.setColor(SK_ColorRED); 43 paint.setColor(SK_ColorRED);
35 canvas->drawOval(r0, paint); 44 canvas->drawOval(r0, paint);
36 45
37 paint.setColor(0x800000FF); 46 paint.setColor(0x660000FF);
38 paint.setImageFilter(imf); 47 paint.setImageFilter(imf);
39 paint.setXfermodeMode(mode); 48 paint.setXfermodeMode(mode);
40 canvas->drawOval(r1, paint); 49 canvas->drawOval(r1, paint);
41 } 50 }
42 51
43 void onDraw(SkCanvas* canvas) override { 52 void onDraw(SkCanvas* canvas) override {
53 canvas->translate(10, 10);
54
44 // just need an imagefilter to trigger the code-path (which creates a tm p layer) 55 // just need an imagefilter to trigger the code-path (which creates a tm p layer)
45 SkAutoTUnref<SkImageFilter> imf(SkImageFilter::CreateMatrixFilter(SkMatr ix::I(), 56 SkAutoTUnref<SkImageFilter> imf(SkImageFilter::CreateMatrixFilter(SkMatr ix::I(),
46 kNone_ SkFilterQuality)); 57 kNone_ SkFilterQuality));
47 58
48 const SkXfermode::Mode modes[] = { 59 const SkXfermode::Mode modes[] = {
49 SkXfermode::kSrcATop_Mode, SkXfermode::kDstIn_Mode 60 SkXfermode::kSrcATop_Mode, SkXfermode::kDstIn_Mode
50 }; 61 };
51 62
52 for (size_t i = 0; i < SK_ARRAY_COUNT(modes); ++i) { 63 for (size_t i = 0; i < SK_ARRAY_COUNT(modes); ++i) {
53 canvas->save(); 64 canvas->save();
54 this->doDraw(canvas, modes[i], NULL); 65 this->doDraw(canvas, modes[i], NULL);
55 canvas->translate(250, 0); 66 canvas->translate(240, 0);
56 this->doDraw(canvas, modes[i], imf); 67 this->doDraw(canvas, modes[i], imf);
57 canvas->restore(); 68 canvas->restore();
58 69
59 canvas->translate(0, 250); 70 canvas->translate(0, 240);
60 } 71 }
61 } 72 }
62 73
63 private: 74 private:
64 typedef GM INHERITED; 75 typedef GM INHERITED;
65 }; 76 };
66 DEF_GM( return new ImageFilterXfermodeTestGM; ) 77 DEF_GM( return new ImageFilterXfermodeTestGM; )
67 78
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