OLD | NEW |
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 "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 auto tempSurface(this->possiblyCreateTempSurface(canvas, kSize, kSize)); | 62 auto tempSurface(this->possiblyCreateTempSurface(canvas, kSize, kSize)); |
63 | 63 |
64 int test = 0; | 64 int test = 0; |
65 int x = 0, y = 0; | 65 int x = 0, y = 0; |
66 constexpr struct { SkPaint::Style fStyle; SkScalar fWidth; } kStrokes[]
= { | 66 constexpr struct { SkPaint::Style fStyle; SkScalar fWidth; } kStrokes[]
= { |
67 {SkPaint::kFill_Style, 0}, | 67 {SkPaint::kFill_Style, 0}, |
68 {SkPaint::kStroke_Style, SkIntToScalar(kSize) / 2}, | 68 {SkPaint::kStroke_Style, SkIntToScalar(kSize) / 2}, |
69 }; | 69 }; |
70 for (size_t s = 0; s < SK_ARRAY_COUNT(kStrokes); ++s) { | 70 for (size_t s = 0; s < SK_ARRAY_COUNT(kStrokes); ++s) { |
71 for (size_t m = 0; m <= SkXfermode::kLastMode; ++m) { | 71 for (size_t m = 0; m <= SkXfermode::kLastMode; ++m) { |
72 SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(m); | 72 SkBlendMode mode = static_cast<SkBlendMode>(m); |
73 canvas->drawText(SkXfermode::ModeName(mode), | 73 canvas->drawText(SkXfermode::ModeName(mode), |
74 strlen(SkXfermode::ModeName(mode)), | 74 strlen(SkXfermode::ModeName(mode)), |
75 SkIntToScalar(x), | 75 SkIntToScalar(x), |
76 SkIntToScalar(y + kSize + 3) + labelP.getTextSi
ze(), | 76 SkIntToScalar(y + kSize + 3) + labelP.getTextSi
ze(), |
77 labelP); | 77 labelP); |
78 for (size_t c = 0; c < SK_ARRAY_COUNT(kSolidColors); ++c) { | 78 for (size_t c = 0; c < SK_ARRAY_COUNT(kSolidColors); ++c) { |
79 SkPaint modePaint; | 79 SkPaint modePaint; |
80 modePaint.setXfermodeMode(mode); | 80 modePaint.setBlendMode(mode); |
81 modePaint.setColor(kSolidColors[c]); | 81 modePaint.setColor(kSolidColors[c]); |
82 modePaint.setStyle(kStrokes[s].fStyle); | 82 modePaint.setStyle(kStrokes[s].fStyle); |
83 modePaint.setStrokeWidth(kStrokes[s].fWidth); | 83 modePaint.setStrokeWidth(kStrokes[s].fWidth); |
84 | 84 |
85 this->drawMode(canvas, x, y, kSize, kSize, modePaint, tempSu
rface.get()); | 85 this->drawMode(canvas, x, y, kSize, kSize, modePaint, tempSu
rface.get()); |
86 | 86 |
87 ++test; | 87 ++test; |
88 x += kSize + 10; | 88 x += kSize + 10; |
89 if (!(test % kTestsPerRow)) { | 89 if (!(test % kTestsPerRow)) { |
90 x = 0; | 90 x = 0; |
91 y += kSize + 30; | 91 y += kSize + 30; |
92 } | 92 } |
93 } | 93 } |
94 for (size_t a = 0; a < SK_ARRAY_COUNT(kBmpAlphas); ++a) { | 94 for (size_t a = 0; a < SK_ARRAY_COUNT(kBmpAlphas); ++a) { |
95 SkPaint modePaint; | 95 SkPaint modePaint; |
96 modePaint.setXfermodeMode(mode); | 96 modePaint.setBlendMode(mode); |
97 modePaint.setAlpha(kBmpAlphas[a]); | 97 modePaint.setAlpha(kBmpAlphas[a]); |
98 modePaint.setShader(fBmpShader); | 98 modePaint.setShader(fBmpShader); |
99 modePaint.setStyle(kStrokes[s].fStyle); | 99 modePaint.setStyle(kStrokes[s].fStyle); |
100 modePaint.setStrokeWidth(kStrokes[s].fWidth); | 100 modePaint.setStrokeWidth(kStrokes[s].fWidth); |
101 | 101 |
102 this->drawMode(canvas, x, y, kSize, kSize, modePaint, tempSu
rface.get()); | 102 this->drawMode(canvas, x, y, kSize, kSize, modePaint, tempSu
rface.get()); |
103 | 103 |
104 ++test; | 104 ++test; |
105 x += kSize + 10; | 105 x += kSize + 10; |
106 if (!(test % kTestsPerRow)) { | 106 if (!(test % kTestsPerRow)) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 sk_sp<SkShader> fBmpShader; | 221 sk_sp<SkShader> fBmpShader; |
222 | 222 |
223 typedef GM INHERITED; | 223 typedef GM INHERITED; |
224 }; | 224 }; |
225 | 225 |
226 ////////////////////////////////////////////////////////////////////////////// | 226 ////////////////////////////////////////////////////////////////////////////// |
227 | 227 |
228 DEF_GM(return new Xfermodes3GM;) | 228 DEF_GM(return new Xfermodes3GM;) |
229 | 229 |
230 } | 230 } |
OLD | NEW |