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