OLD | NEW |
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" |
(...skipping 13 matching lines...) Expand all Loading... |
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); | 28 SkAutoCanvasRestore acr(canvas, true); |
29 canvas->clipRect(SkRect::MakeWH(220, 220)); | 29 canvas->clipRect(SkRect::MakeWH(220, 220)); |
30 | 30 |
31 // want to force a layer, so modes like DstIn can combine meaningfully,
but the final | 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 | 32 // image can still be shown against our default (opaque) background. non
-opaque GMs |
33 // are a lot more trouble to compare/triage. | 33 // are a lot more trouble to compare/triage. |
34 canvas->saveLayer(NULL, NULL); | 34 canvas->saveLayer(nullptr, nullptr); |
35 canvas->drawColor(SK_ColorGREEN); | 35 canvas->drawColor(SK_ColorGREEN); |
36 | 36 |
37 SkPaint paint; | 37 SkPaint paint; |
38 paint.setAntiAlias(true); | 38 paint.setAntiAlias(true); |
39 | 39 |
40 SkRect r0 = SkRect::MakeXYWH(10, 60, 200, 100); | 40 SkRect r0 = SkRect::MakeXYWH(10, 60, 200, 100); |
41 SkRect r1 = SkRect::MakeXYWH(60, 10, 100, 200); | 41 SkRect r1 = SkRect::MakeXYWH(60, 10, 100, 200); |
42 | 42 |
43 paint.setColor(SK_ColorRED); | 43 paint.setColor(SK_ColorRED); |
44 canvas->drawOval(r0, paint); | 44 canvas->drawOval(r0, paint); |
(...skipping 10 matching lines...) Expand all Loading... |
55 // 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) |
56 SkAutoTUnref<SkImageFilter> imf(SkImageFilter::CreateMatrixFilter(SkMatr
ix::I(), | 56 SkAutoTUnref<SkImageFilter> imf(SkImageFilter::CreateMatrixFilter(SkMatr
ix::I(), |
57 kNone_
SkFilterQuality)); | 57 kNone_
SkFilterQuality)); |
58 | 58 |
59 const SkXfermode::Mode modes[] = { | 59 const SkXfermode::Mode modes[] = { |
60 SkXfermode::kSrcATop_Mode, SkXfermode::kDstIn_Mode | 60 SkXfermode::kSrcATop_Mode, SkXfermode::kDstIn_Mode |
61 }; | 61 }; |
62 | 62 |
63 for (size_t i = 0; i < SK_ARRAY_COUNT(modes); ++i) { | 63 for (size_t i = 0; i < SK_ARRAY_COUNT(modes); ++i) { |
64 canvas->save(); | 64 canvas->save(); |
65 this->doDraw(canvas, modes[i], NULL); | 65 this->doDraw(canvas, modes[i], nullptr); |
66 canvas->translate(240, 0); | 66 canvas->translate(240, 0); |
67 this->doDraw(canvas, modes[i], imf); | 67 this->doDraw(canvas, modes[i], imf); |
68 canvas->restore(); | 68 canvas->restore(); |
69 | 69 |
70 canvas->translate(0, 240); | 70 canvas->translate(0, 240); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 private: | 74 private: |
75 typedef GM INHERITED; | 75 typedef GM INHERITED; |
76 }; | 76 }; |
77 DEF_GM( return new ImageFilterXfermodeTestGM; ) | 77 DEF_GM( return new ImageFilterXfermodeTestGM; ) |
78 | 78 |
OLD | NEW |