epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 8 | #include "gm.h" |
| 9 | #include "SkBitmap.h" |
| 10 | #include "SkShader.h" |
| 11 | #include "SkXfermode.h" |
| 12 | |
| 13 | namespace skiagm { |
| 14 | |
commit-bot@chromium.org | 7542dc8 | 2013-12-03 21:08:46 +0000 | [diff] [blame] | 15 | static void make_bitmaps(int w, int h, SkBitmap* src, SkBitmap* dst, |
| 16 | SkBitmap* transparent) { |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 17 | src->setConfig(SkBitmap::kARGB_8888_Config, w, h); |
| 18 | src->allocPixels(); |
junov@google.com | dbfac8a | 2012-12-06 21:47:40 +0000 | [diff] [blame] | 19 | src->eraseColor(SK_ColorTRANSPARENT); |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 20 | |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 21 | SkPaint p; |
mike@reedtribe.org | 3bd2173 | 2012-09-26 02:45:10 +0000 | [diff] [blame] | 22 | p.setAntiAlias(true); |
| 23 | |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 24 | SkRect r; |
| 25 | SkScalar ww = SkIntToScalar(w); |
| 26 | SkScalar hh = SkIntToScalar(h); |
| 27 | |
mike@reedtribe.org | 3bd2173 | 2012-09-26 02:45:10 +0000 | [diff] [blame] | 28 | { |
| 29 | SkCanvas c(*src); |
| 30 | p.setColor(0xFFFFCC44); |
| 31 | r.set(0, 0, ww*3/4, hh*3/4); |
| 32 | c.drawOval(r, p); |
| 33 | } |
tomhudson@google.com | 86bf5c9 | 2011-04-26 18:15:03 +0000 | [diff] [blame] | 34 | |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 35 | dst->setConfig(SkBitmap::kARGB_8888_Config, w, h); |
| 36 | dst->allocPixels(); |
junov@google.com | dbfac8a | 2012-12-06 21:47:40 +0000 | [diff] [blame] | 37 | dst->eraseColor(SK_ColorTRANSPARENT); |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 38 | |
mike@reedtribe.org | 3bd2173 | 2012-09-26 02:45:10 +0000 | [diff] [blame] | 39 | { |
| 40 | SkCanvas c(*dst); |
| 41 | p.setColor(0xFF66AAFF); |
| 42 | r.set(ww/3, hh/3, ww*19/20, hh*19/20); |
| 43 | c.drawRect(r, p); |
| 44 | } |
commit-bot@chromium.org | 7542dc8 | 2013-12-03 21:08:46 +0000 | [diff] [blame] | 45 | |
| 46 | transparent->setConfig(SkBitmap::kARGB_8888_Config, w, h); |
| 47 | transparent->allocPixels(); |
| 48 | transparent->eraseColor(SK_ColorTRANSPARENT); |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 49 | } |
| 50 | |
scroggo@google.com | 7312a18 | 2013-01-28 21:14:21 +0000 | [diff] [blame] | 51 | static uint16_t gData[] = { 0xFFFF, 0xCCCF, 0xCCCF, 0xFFFF }; |
| 52 | |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 53 | class XfermodesGM : public GM { |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 54 | enum SrcType { |
| 55 | //! A WxH image with a rectangle in the lower right. |
| 56 | kRectangleImage_SrcType = 0x01, |
| 57 | //! kRectangleImage_SrcType with an alpha of 34.5%. |
| 58 | kRectangleImageWithAlpha_SrcType = 0x02, |
| 59 | //! kRectnagleImageWithAlpha_SrcType scaled down by half. |
| 60 | kSmallRectangleImageWithAlpha_SrcType = 0x04, |
| 61 | //! kRectangleImage_SrcType drawn directly instead in an image. |
| 62 | kRectangle_SrcType = 0x08, |
| 63 | //! Two rectangles, first on the right half, second on the bottom half. |
| 64 | kQuarterClear_SrcType = 0x10, |
| 65 | //! kQuarterClear_SrcType in a layer. |
| 66 | kQuarterClearInLayer_SrcType = 0x20, |
commit-bot@chromium.org | 7542dc8 | 2013-12-03 21:08:46 +0000 | [diff] [blame] | 67 | //! A W/2xH/2 transparent image. |
| 68 | kSmallTransparentImage_SrcType = 0x40, |
commit-bot@chromium.org | 4e8f1e5 | 2013-12-17 23:38:28 +0000 | [diff] [blame] | 69 | //! kRectangleImage_SrcType drawn directly with a mask. |
| 70 | kRectangleWithMask_SrcType = 0x80, |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 71 | |
commit-bot@chromium.org | 4e8f1e5 | 2013-12-17 23:38:28 +0000 | [diff] [blame] | 72 | kAll_SrcType = 0xFF, //!< All the source types. |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 73 | kBasic_SrcType = 0x03, //!< Just basic source types. |
| 74 | }; |
| 75 | |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 76 | SkBitmap fBG; |
commit-bot@chromium.org | 7542dc8 | 2013-12-03 21:08:46 +0000 | [diff] [blame] | 77 | SkBitmap fSrcB, fDstB, fTransparent; |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 78 | |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 79 | /* The srcType argument indicates what to draw for the source part. Skia |
| 80 | * uses the implied shape of the drawing command and these modes |
| 81 | * demonstrate that. |
| 82 | */ |
| 83 | void draw_mode(SkCanvas* canvas, SkXfermode* mode, SrcType srcType, |
reed@google.com | f3c1cc9 | 2010-12-23 16:45:33 +0000 | [diff] [blame] | 84 | SkScalar x, SkScalar y) { |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 85 | SkPaint p; |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 86 | SkMatrix m; |
| 87 | bool restoreNeeded = false; |
| 88 | m.setTranslate(x, y); |
tomhudson@google.com | 86bf5c9 | 2011-04-26 18:15:03 +0000 | [diff] [blame] | 89 | |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 90 | canvas->drawBitmapMatrix(fSrcB, m, &p); |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 91 | p.setXfermode(mode); |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 92 | switch (srcType) { |
commit-bot@chromium.org | 7542dc8 | 2013-12-03 21:08:46 +0000 | [diff] [blame] | 93 | case kSmallTransparentImage_SrcType: |
| 94 | m.postScale(SK_ScalarHalf, SK_ScalarHalf, x, y); |
| 95 | canvas->drawBitmapMatrix(fTransparent, m, &p); |
| 96 | break; |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 97 | case kQuarterClearInLayer_SrcType: { |
vandebo@chromium.org | f5747da | 2013-10-30 21:29:47 +0000 | [diff] [blame] | 98 | SkRect bounds = SkRect::MakeXYWH(x, y, SkIntToScalar(W), |
| 99 | SkIntToScalar(H)); |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 100 | canvas->saveLayer(&bounds, &p); |
| 101 | restoreNeeded = true; |
| 102 | p.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
| 103 | // Fall through. |
| 104 | } |
| 105 | case kQuarterClear_SrcType: { |
| 106 | SkScalar halfW = SkIntToScalar(W) / 2; |
| 107 | SkScalar halfH = SkIntToScalar(H) / 2; |
| 108 | p.setColor(0xFF66AAFF); |
vandebo@chromium.org | f5747da | 2013-10-30 21:29:47 +0000 | [diff] [blame] | 109 | SkRect r = SkRect::MakeXYWH(x + halfW, y, halfW, |
| 110 | SkIntToScalar(H)); |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 111 | canvas->drawRect(r, p); |
| 112 | p.setColor(0xFFAA66FF); |
vandebo@chromium.org | f5747da | 2013-10-30 21:29:47 +0000 | [diff] [blame] | 113 | r = SkRect::MakeXYWH(x, y + halfH, SkIntToScalar(W), halfH); |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 114 | canvas->drawRect(r, p); |
| 115 | break; |
| 116 | } |
commit-bot@chromium.org | 4e8f1e5 | 2013-12-17 23:38:28 +0000 | [diff] [blame] | 117 | case kRectangleWithMask_SrcType: { |
| 118 | canvas->save(SkCanvas::kClip_SaveFlag); |
| 119 | restoreNeeded = true; |
| 120 | SkScalar w = SkIntToScalar(W); |
| 121 | SkScalar h = SkIntToScalar(H); |
| 122 | SkRect r = SkRect::MakeXYWH(x, y + h / 4, w, h * 23 / 60); |
| 123 | canvas->clipRect(r); |
| 124 | // Fall through. |
| 125 | } |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 126 | case kRectangle_SrcType: { |
| 127 | SkScalar w = SkIntToScalar(W); |
| 128 | SkScalar h = SkIntToScalar(H); |
| 129 | SkRect r = SkRect::MakeXYWH(x + w / 3, y + h / 3, |
| 130 | w * 37 / 60, h * 37 / 60); |
| 131 | p.setColor(0xFF66AAFF); |
| 132 | canvas->drawRect(r, p); |
| 133 | break; |
| 134 | } |
| 135 | case kSmallRectangleImageWithAlpha_SrcType: |
| 136 | m.postScale(SK_ScalarHalf, SK_ScalarHalf, x, y); |
| 137 | // Fall through. |
| 138 | case kRectangleImageWithAlpha_SrcType: |
| 139 | p.setAlpha(0x88); |
| 140 | // Fall through. |
| 141 | case kRectangleImage_SrcType: |
| 142 | canvas->drawBitmapMatrix(fDstB, m, &p); |
| 143 | break; |
| 144 | default: |
| 145 | break; |
| 146 | } |
| 147 | |
| 148 | if (restoreNeeded) { |
| 149 | canvas->restore(); |
| 150 | } |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 151 | } |
tomhudson@google.com | 86bf5c9 | 2011-04-26 18:15:03 +0000 | [diff] [blame] | 152 | |
scroggo@google.com | 7312a18 | 2013-01-28 21:14:21 +0000 | [diff] [blame] | 153 | virtual void onOnceBeforeDraw() SK_OVERRIDE { |
reed@google.com | 383a697 | 2013-10-21 14:00:07 +0000 | [diff] [blame] | 154 | fBG.setConfig(SkBitmap::kARGB_4444_Config, 2, 2, 4, kOpaque_SkAlphaType); |
scroggo@google.com | 7312a18 | 2013-01-28 21:14:21 +0000 | [diff] [blame] | 155 | fBG.setPixels(gData); |
rmistry@google.com | ae933ce | 2012-08-23 18:19:56 +0000 | [diff] [blame] | 156 | |
commit-bot@chromium.org | 7542dc8 | 2013-12-03 21:08:46 +0000 | [diff] [blame] | 157 | make_bitmaps(W, H, &fSrcB, &fDstB, &fTransparent); |
reed@google.com | 5213c04 | 2011-12-20 13:41:09 +0000 | [diff] [blame] | 158 | } |
| 159 | |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 160 | public: |
reed@google.com | f3c1cc9 | 2010-12-23 16:45:33 +0000 | [diff] [blame] | 161 | const static int W = 64; |
| 162 | const static int H = 64; |
scroggo@google.com | 7312a18 | 2013-01-28 21:14:21 +0000 | [diff] [blame] | 163 | XfermodesGM() {} |
tomhudson@google.com | 86bf5c9 | 2011-04-26 18:15:03 +0000 | [diff] [blame] | 164 | |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 165 | protected: |
reed@android.com | 048522d | 2009-06-23 12:19:41 +0000 | [diff] [blame] | 166 | virtual SkString onShortName() { |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 167 | return SkString("xfermodes"); |
| 168 | } |
| 169 | |
tomhudson@google.com | 86bf5c9 | 2011-04-26 18:15:03 +0000 | [diff] [blame] | 170 | virtual SkISize onISize() { |
commit-bot@chromium.org | 7542dc8 | 2013-12-03 21:08:46 +0000 | [diff] [blame] | 171 | return make_isize(1990, 640); |
reed@android.com | 048522d | 2009-06-23 12:19:41 +0000 | [diff] [blame] | 172 | } |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 173 | |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 174 | virtual void onDraw(SkCanvas* canvas) { |
reed@google.com | f3c1cc9 | 2010-12-23 16:45:33 +0000 | [diff] [blame] | 175 | canvas->translate(SkIntToScalar(10), SkIntToScalar(20)); |
tomhudson@google.com | 86bf5c9 | 2011-04-26 18:15:03 +0000 | [diff] [blame] | 176 | |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 177 | const struct { |
reed@google.com | f3c1cc9 | 2010-12-23 16:45:33 +0000 | [diff] [blame] | 178 | SkXfermode::Mode fMode; |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 179 | const char* fLabel; |
| 180 | int fSourceTypeMask; // The source types to use this |
| 181 | // mode with. See draw_mode for |
| 182 | // an explanation of each type. |
| 183 | // PDF has to play some tricks |
| 184 | // to support the base modes, |
| 185 | // test those more extensively. |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 186 | } gModes[] = { |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 187 | { SkXfermode::kClear_Mode, "Clear", kAll_SrcType }, |
| 188 | { SkXfermode::kSrc_Mode, "Src", kAll_SrcType }, |
| 189 | { SkXfermode::kDst_Mode, "Dst", kAll_SrcType }, |
| 190 | { SkXfermode::kSrcOver_Mode, "SrcOver", kAll_SrcType }, |
| 191 | { SkXfermode::kDstOver_Mode, "DstOver", kAll_SrcType }, |
| 192 | { SkXfermode::kSrcIn_Mode, "SrcIn", kAll_SrcType }, |
| 193 | { SkXfermode::kDstIn_Mode, "DstIn", kAll_SrcType }, |
| 194 | { SkXfermode::kSrcOut_Mode, "SrcOut", kAll_SrcType }, |
| 195 | { SkXfermode::kDstOut_Mode, "DstOut", kAll_SrcType }, |
| 196 | { SkXfermode::kSrcATop_Mode, "SrcATop", kAll_SrcType }, |
| 197 | { SkXfermode::kDstATop_Mode, "DstATop", kAll_SrcType }, |
tomhudson@google.com | 86bf5c9 | 2011-04-26 18:15:03 +0000 | [diff] [blame] | 198 | |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 199 | { SkXfermode::kXor_Mode, "Xor", kBasic_SrcType }, |
| 200 | { SkXfermode::kPlus_Mode, "Plus", kBasic_SrcType }, |
| 201 | { SkXfermode::kModulate_Mode, "Modulate", kAll_SrcType }, |
| 202 | { SkXfermode::kScreen_Mode, "Screen", kBasic_SrcType }, |
| 203 | { SkXfermode::kOverlay_Mode, "Overlay", kBasic_SrcType }, |
| 204 | { SkXfermode::kDarken_Mode, "Darken", kBasic_SrcType }, |
| 205 | { SkXfermode::kLighten_Mode, "Lighten", kBasic_SrcType }, |
| 206 | { SkXfermode::kColorDodge_Mode, "ColorDodge", kBasic_SrcType }, |
| 207 | { SkXfermode::kColorBurn_Mode, "ColorBurn", kBasic_SrcType }, |
| 208 | { SkXfermode::kHardLight_Mode, "HardLight", kBasic_SrcType }, |
| 209 | { SkXfermode::kSoftLight_Mode, "SoftLight", kBasic_SrcType }, |
| 210 | { SkXfermode::kDifference_Mode, "Difference", kBasic_SrcType }, |
| 211 | { SkXfermode::kExclusion_Mode, "Exclusion", kBasic_SrcType }, |
| 212 | { SkXfermode::kMultiply_Mode, "Multiply", kAll_SrcType }, |
| 213 | { SkXfermode::kHue_Mode, "Hue", kBasic_SrcType }, |
| 214 | { SkXfermode::kSaturation_Mode, "Saturation", kBasic_SrcType }, |
| 215 | { SkXfermode::kColor_Mode, "Color", kBasic_SrcType }, |
| 216 | { SkXfermode::kLuminosity_Mode, "Luminosity", kBasic_SrcType }, |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 217 | }; |
tomhudson@google.com | 86bf5c9 | 2011-04-26 18:15:03 +0000 | [diff] [blame] | 218 | |
reed@google.com | f3c1cc9 | 2010-12-23 16:45:33 +0000 | [diff] [blame] | 219 | const SkScalar w = SkIntToScalar(W); |
| 220 | const SkScalar h = SkIntToScalar(H); |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 221 | SkShader* s = SkShader::CreateBitmapShader(fBG, |
| 222 | SkShader::kRepeat_TileMode, |
| 223 | SkShader::kRepeat_TileMode); |
| 224 | SkMatrix m; |
| 225 | m.setScale(SkIntToScalar(6), SkIntToScalar(6)); |
| 226 | s->setLocalMatrix(m); |
tomhudson@google.com | 86bf5c9 | 2011-04-26 18:15:03 +0000 | [diff] [blame] | 227 | |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 228 | SkPaint labelP; |
| 229 | labelP.setAntiAlias(true); |
| 230 | labelP.setTextAlign(SkPaint::kCenter_Align); |
tomhudson@google.com | 86bf5c9 | 2011-04-26 18:15:03 +0000 | [diff] [blame] | 231 | |
reed@android.com | c9c6422 | 2009-06-23 00:09:12 +0000 | [diff] [blame] | 232 | const int W = 5; |
tomhudson@google.com | 86bf5c9 | 2011-04-26 18:15:03 +0000 | [diff] [blame] | 233 | |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 234 | SkScalar x0 = 0; |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 235 | SkScalar y0 = 0; |
| 236 | for (int sourceType = 1; sourceType & kAll_SrcType; sourceType <<= 1) { |
| 237 | SkScalar x = x0, y = y0; |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 238 | for (size_t i = 0; i < SK_ARRAY_COUNT(gModes); i++) { |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 239 | if ((gModes[i].fSourceTypeMask & sourceType) == 0) { |
| 240 | continue; |
| 241 | } |
reed@android.com | c9c6422 | 2009-06-23 00:09:12 +0000 | [diff] [blame] | 242 | SkXfermode* mode = SkXfermode::Create(gModes[i].fMode); |
reed@google.com | f3c1cc9 | 2010-12-23 16:45:33 +0000 | [diff] [blame] | 243 | SkAutoUnref aur(mode); |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 244 | SkRect r; |
| 245 | r.set(x, y, x+w, y+h); |
tomhudson@google.com | 86bf5c9 | 2011-04-26 18:15:03 +0000 | [diff] [blame] | 246 | |
reed@google.com | f3c1cc9 | 2010-12-23 16:45:33 +0000 | [diff] [blame] | 247 | SkPaint p; |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 248 | p.setStyle(SkPaint::kFill_Style); |
| 249 | p.setShader(s); |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 250 | canvas->drawRect(r, p); |
tomhudson@google.com | 86bf5c9 | 2011-04-26 18:15:03 +0000 | [diff] [blame] | 251 | |
reed@google.com | f3c1cc9 | 2010-12-23 16:45:33 +0000 | [diff] [blame] | 252 | canvas->saveLayer(&r, NULL, SkCanvas::kARGB_ClipLayer_SaveFlag); |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 253 | draw_mode(canvas, mode, static_cast<SrcType>(sourceType), |
| 254 | r.fLeft, r.fTop); |
reed@google.com | f3c1cc9 | 2010-12-23 16:45:33 +0000 | [diff] [blame] | 255 | canvas->restore(); |
tomhudson@google.com | 86bf5c9 | 2011-04-26 18:15:03 +0000 | [diff] [blame] | 256 | |
reed@google.com | f3c1cc9 | 2010-12-23 16:45:33 +0000 | [diff] [blame] | 257 | r.inset(-SK_ScalarHalf, -SK_ScalarHalf); |
| 258 | p.setStyle(SkPaint::kStroke_Style); |
| 259 | p.setShader(NULL); |
| 260 | canvas->drawRect(r, p); |
tomhudson@google.com | 86bf5c9 | 2011-04-26 18:15:03 +0000 | [diff] [blame] | 261 | |
reed@google.com | f3c1cc9 | 2010-12-23 16:45:33 +0000 | [diff] [blame] | 262 | #if 1 |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 263 | canvas->drawText(gModes[i].fLabel, strlen(gModes[i].fLabel), |
| 264 | x + w/2, y - labelP.getTextSize()/2, labelP); |
reed@google.com | f3c1cc9 | 2010-12-23 16:45:33 +0000 | [diff] [blame] | 265 | #endif |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 266 | x += w + SkIntToScalar(10); |
reed@android.com | c9c6422 | 2009-06-23 00:09:12 +0000 | [diff] [blame] | 267 | if ((i % W) == W - 1) { |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 268 | x = x0; |
| 269 | y += h + SkIntToScalar(30); |
| 270 | } |
| 271 | } |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 272 | if (y < 320) { |
| 273 | if (x > x0) { |
| 274 | y += h + SkIntToScalar(30); |
| 275 | } |
| 276 | y0 = y; |
| 277 | } else { |
| 278 | x0 += SkIntToScalar(400); |
| 279 | y0 = 0; |
| 280 | } |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 281 | } |
| 282 | s->unref(); |
| 283 | } |
| 284 | |
| 285 | private: |
| 286 | typedef GM INHERITED; |
| 287 | }; |
| 288 | |
| 289 | ////////////////////////////////////////////////////////////////////////////// |
| 290 | |
| 291 | static GM* MyFactory(void*) { return new XfermodesGM; } |
| 292 | static GMRegistry reg(MyFactory); |
| 293 | |
| 294 | } |