tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "gm.h" |
| 9 | #include "SkCanvas.h" |
| 10 | #include "SkPath.h" |
| 11 | |
reed | 02f9ed7 | 2016-09-06 09:06:18 -0700 | [diff] [blame] | 12 | static void do_draw(SkCanvas* canvas, const SkRect& r) { |
| 13 | SkPaint paint; |
reed | 374772b | 2016-10-05 17:33:02 -0700 | [diff] [blame] | 14 | paint.setBlendMode(SkBlendMode::kSrc); |
reed | 02f9ed7 | 2016-09-06 09:06:18 -0700 | [diff] [blame] | 15 | paint.setColor(0x800000FF); |
| 16 | canvas->drawRect(r, paint); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Exercise kDontClipToLayer_Legacy_SaveLayerFlag flag, which does not limit the clip to the |
| 21 | * layer's bounds. Thus when a draw occurs, it can (depending on "where" it is) draw into the layer |
| 22 | * and/or draw onto the surrounding portions of the canvas, or both. |
| 23 | * |
| 24 | * This GM has a 100x100 rectangle (r), which its going to draw. However first it creates a layer |
| 25 | * with this flag covering 1/2 of the rectangle (upper half). Then it draws the rect in SRC mode. |
| 26 | * |
| 27 | * The portion of the draw that intersects the layer should see the SRC draw, apply it to the layer |
| 28 | * and then during restore, it will SRC_OVER that layer onto the canvas (SRC_OVER since the layer |
| 29 | * has no paint, so it gets the default xfermode during restore). |
| 30 | * |
reed | 28d1ce5 | 2016-09-06 14:57:00 -0700 | [diff] [blame] | 31 | * Note: when we talk about drawing directly into the "canvas", in fact we are drawing into an |
| 32 | * "outer" layer we created (filled with red). This is a testing detail, so that our final |
| 33 | * output image is itself opaque, otherwise we make it harder to view the GM as a PNG. |
reed | 02f9ed7 | 2016-09-06 09:06:18 -0700 | [diff] [blame] | 34 | * |
reed | 28d1ce5 | 2016-09-06 14:57:00 -0700 | [diff] [blame] | 35 | * The portion of the draw below the layer draws directly into the canvas. Since it is in SRC mode, |
| 36 | * it will write 0x80 to the canvas' alpha, overwriting the "red", which then gets blended with |
| 37 | * the GM's white background. |
| 38 | * |
| 39 | * The portion in the layer, will end up SRC_OVERing the 0x80 layer pixels onto the canvas' red |
| 40 | * pixels, making magenta. |
| 41 | * |
| 42 | * Thus the expected result is the upper half to be magenta 0xFF7F0080, and the lower half to be |
| 43 | * light blue 0xFF7F7FFF. |
reed | 02f9ed7 | 2016-09-06 09:06:18 -0700 | [diff] [blame] | 44 | */ |
| 45 | DEF_SIMPLE_GM(dont_clip_to_layer, canvas, 120, 120) { |
reed | 28d1ce5 | 2016-09-06 14:57:00 -0700 | [diff] [blame] | 46 | const SkRect r { 10, 10, 110, 110 }; |
| 47 | |
| 48 | // Wrap the entire test inside a red layer, so we don't punch the actual gm's alpha with |
| 49 | // kSrc_Mode, which makes it hard to view (we like our GMs to have opaque pixels). |
| 50 | canvas->saveLayer(&r, nullptr); |
| 51 | canvas->drawColor(SK_ColorRED); |
| 52 | |
reed | 02f9ed7 | 2016-09-06 09:06:18 -0700 | [diff] [blame] | 53 | SkRect r0 = SkRect::MakeXYWH(r.left(), r.top(), r.width(), r.height()/2); |
| 54 | |
| 55 | SkCanvas::SaveLayerRec rec; |
| 56 | rec.fPaint = nullptr; |
| 57 | rec.fBounds = &r0; |
| 58 | rec.fBackdrop = nullptr; |
| 59 | rec.fSaveLayerFlags = 1 << 31;//SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag; |
| 60 | canvas->saveLayer(rec); |
| 61 | do_draw(canvas, r); |
| 62 | canvas->restore(); |
reed | 28d1ce5 | 2016-09-06 14:57:00 -0700 | [diff] [blame] | 63 | |
| 64 | canvas->restore(); // red-layer |
reed | 02f9ed7 | 2016-09-06 09:06:18 -0700 | [diff] [blame] | 65 | } |
| 66 | |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 67 | /** Draw a 2px border around the target, then red behind the target; |
| 68 | set the clip to match the target, then draw >> the target in blue. |
| 69 | */ |
| 70 | |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 71 | static void draw(SkCanvas* canvas, SkRect& target, int x, int y) { |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 72 | SkPaint borderPaint; |
| 73 | borderPaint.setColor(SkColorSetRGB(0x0, 0xDD, 0x0)); |
| 74 | borderPaint.setAntiAlias(true); |
| 75 | SkPaint backgroundPaint; |
| 76 | backgroundPaint.setColor(SkColorSetRGB(0xDD, 0x0, 0x0)); |
| 77 | backgroundPaint.setAntiAlias(true); |
| 78 | SkPaint foregroundPaint; |
| 79 | foregroundPaint.setColor(SkColorSetRGB(0x0, 0x0, 0xDD)); |
| 80 | foregroundPaint.setAntiAlias(true); |
| 81 | |
| 82 | canvas->save(); |
tomhudson@google.com | abfa8d1 | 2011-12-28 19:40:48 +0000 | [diff] [blame] | 83 | canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); |
| 84 | target.inset(SkIntToScalar(-2), SkIntToScalar(-2)); |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 85 | canvas->drawRect(target, borderPaint); |
tomhudson@google.com | abfa8d1 | 2011-12-28 19:40:48 +0000 | [diff] [blame] | 86 | target.inset(SkIntToScalar(2), SkIntToScalar(2)); |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 87 | canvas->drawRect(target, backgroundPaint); |
reed | 6699838 | 2016-09-21 11:15:07 -0700 | [diff] [blame] | 88 | canvas->clipRect(target, true); |
tomhudson@google.com | abfa8d1 | 2011-12-28 19:40:48 +0000 | [diff] [blame] | 89 | target.inset(SkIntToScalar(-4), SkIntToScalar(-4)); |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 90 | canvas->drawRect(target, foregroundPaint); |
| 91 | canvas->restore(); |
| 92 | } |
| 93 | |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 94 | static void draw_square(SkCanvas* canvas, int x, int y) { |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 95 | SkRect target (SkRect::MakeWH(10 * SK_Scalar1, 10 * SK_Scalar1)); |
| 96 | draw(canvas, target, x, y); |
| 97 | } |
| 98 | |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 99 | static void draw_column(SkCanvas* canvas, int x, int y) { |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 100 | SkRect target (SkRect::MakeWH(1 * SK_Scalar1, 10 * SK_Scalar1)); |
| 101 | draw(canvas, target, x, y); |
| 102 | } |
| 103 | |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 104 | static void draw_bar(SkCanvas* canvas, int x, int y) { |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 105 | SkRect target (SkRect::MakeWH(10 * SK_Scalar1, 1 * SK_Scalar1)); |
| 106 | draw(canvas, target, x, y); |
| 107 | } |
| 108 | |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 109 | static void draw_rect_tests(SkCanvas* canvas) { |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 110 | draw_square(canvas, 10, 10); |
| 111 | draw_column(canvas, 30, 10); |
| 112 | draw_bar(canvas, 10, 30); |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | Test a set of clipping problems discovered while writing blitAntiRect, |
| 117 | and test all the code paths through the clipping blitters. |
| 118 | Each region should show as a blue center surrounded by a 2px green |
| 119 | border, with no red. |
| 120 | */ |
| 121 | |
reed@google.com | ff26b7e | 2013-05-23 17:04:19 +0000 | [diff] [blame] | 122 | class AAClipGM : public skiagm::GM { |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 123 | public: |
| 124 | AAClipGM() { |
reed@google.com | 7112173 | 2012-09-18 15:14:33 +0000 | [diff] [blame] | 125 | |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | protected: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 129 | SkString onShortName() override { |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 130 | return SkString("aaclip"); |
| 131 | } |
| 132 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 133 | SkISize onISize() override { |
commit-bot@chromium.org | 5d0b150 | 2014-04-14 15:02:19 +0000 | [diff] [blame] | 134 | return SkISize::Make(240, 120); |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 135 | } |
| 136 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 137 | void onDraw(SkCanvas* canvas) override { |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 138 | // Initial pixel-boundary-aligned draw |
| 139 | draw_rect_tests(canvas); |
| 140 | |
| 141 | // Repeat 4x with .2, .4, .6, .8 px offsets |
| 142 | canvas->translate(SK_Scalar1 / 5, SK_Scalar1 / 5); |
tomhudson@google.com | abfa8d1 | 2011-12-28 19:40:48 +0000 | [diff] [blame] | 143 | canvas->translate(SkIntToScalar(50), 0); |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 144 | draw_rect_tests(canvas); |
| 145 | |
| 146 | canvas->translate(SK_Scalar1 / 5, SK_Scalar1 / 5); |
tomhudson@google.com | abfa8d1 | 2011-12-28 19:40:48 +0000 | [diff] [blame] | 147 | canvas->translate(SkIntToScalar(50), 0); |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 148 | draw_rect_tests(canvas); |
| 149 | |
| 150 | canvas->translate(SK_Scalar1 / 5, SK_Scalar1 / 5); |
tomhudson@google.com | abfa8d1 | 2011-12-28 19:40:48 +0000 | [diff] [blame] | 151 | canvas->translate(SkIntToScalar(50), 0); |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 152 | draw_rect_tests(canvas); |
| 153 | |
| 154 | canvas->translate(SK_Scalar1 / 5, SK_Scalar1 / 5); |
tomhudson@google.com | abfa8d1 | 2011-12-28 19:40:48 +0000 | [diff] [blame] | 155 | canvas->translate(SkIntToScalar(50), 0); |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 156 | draw_rect_tests(canvas); |
| 157 | } |
| 158 | |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 159 | private: |
reed@google.com | ff26b7e | 2013-05-23 17:04:19 +0000 | [diff] [blame] | 160 | typedef skiagm::GM INHERITED; |
tomhudson@google.com | ef279d3 | 2011-12-21 14:27:14 +0000 | [diff] [blame] | 161 | }; |
| 162 | |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 163 | DEF_GM(return new AAClipGM;) |
commit-bot@chromium.org | 60b5dce | 2014-04-22 20:24:33 +0000 | [diff] [blame] | 164 | |
| 165 | ///////////////////////////////////////////////////////////////////////// |
| 166 | |
| 167 | #ifdef SK_BUILD_FOR_MAC |
| 168 | |
| 169 | static SkCanvas* make_canvas(const SkBitmap& bm) { |
| 170 | const SkImageInfo& info = bm.info(); |
| 171 | if (info.bytesPerPixel() == 4) { |
| 172 | return SkCanvas::NewRasterDirectN32(info.width(), info.height(), |
| 173 | (SkPMColor*)bm.getPixels(), |
| 174 | bm.rowBytes()); |
| 175 | } else { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 176 | return new SkCanvas(bm); |
commit-bot@chromium.org | 60b5dce | 2014-04-22 20:24:33 +0000 | [diff] [blame] | 177 | } |
| 178 | } |
| 179 | |
| 180 | #include "SkCGUtils.h" |
| 181 | static void test_image(SkCanvas* canvas, const SkImageInfo& info) { |
| 182 | SkBitmap bm; |
| 183 | bm.allocPixels(info); |
| 184 | |
Hal Canary | cefc431 | 2016-11-04 16:26:16 -0400 | [diff] [blame] | 185 | sk_sp<SkCanvas> newc(make_canvas(bm)); |
commit-bot@chromium.org | 60b5dce | 2014-04-22 20:24:33 +0000 | [diff] [blame] | 186 | if (info.isOpaque()) { |
| 187 | bm.eraseColor(SK_ColorGREEN); |
| 188 | } else { |
| 189 | bm.eraseColor(0); |
| 190 | } |
skia.committer@gmail.com | ede0c5c | 2014-04-23 03:04:11 +0000 | [diff] [blame] | 191 | |
commit-bot@chromium.org | 60b5dce | 2014-04-22 20:24:33 +0000 | [diff] [blame] | 192 | SkPaint paint; |
| 193 | paint.setAntiAlias(true); |
| 194 | paint.setColor(SK_ColorBLUE); |
| 195 | newc->drawCircle(50, 50, 49, paint); |
| 196 | canvas->drawBitmap(bm, 10, 10); |
skia.committer@gmail.com | ede0c5c | 2014-04-23 03:04:11 +0000 | [diff] [blame] | 197 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 198 | CGImageRef image = SkCreateCGImageRefWithColorspace(bm, nullptr); |
skia.committer@gmail.com | ede0c5c | 2014-04-23 03:04:11 +0000 | [diff] [blame] | 199 | |
commit-bot@chromium.org | 60b5dce | 2014-04-22 20:24:33 +0000 | [diff] [blame] | 200 | SkBitmap bm2; |
| 201 | SkCreateBitmapFromCGImage(&bm2, image); |
| 202 | CGImageRelease(image); |
skia.committer@gmail.com | ede0c5c | 2014-04-23 03:04:11 +0000 | [diff] [blame] | 203 | |
commit-bot@chromium.org | 60b5dce | 2014-04-22 20:24:33 +0000 | [diff] [blame] | 204 | canvas->drawBitmap(bm2, 10, 120); |
| 205 | } |
| 206 | |
| 207 | class CGImageGM : public skiagm::GM { |
| 208 | public: |
| 209 | CGImageGM() {} |
skia.committer@gmail.com | ede0c5c | 2014-04-23 03:04:11 +0000 | [diff] [blame] | 210 | |
commit-bot@chromium.org | 60b5dce | 2014-04-22 20:24:33 +0000 | [diff] [blame] | 211 | protected: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 212 | SkString onShortName() override { |
commit-bot@chromium.org | 60b5dce | 2014-04-22 20:24:33 +0000 | [diff] [blame] | 213 | return SkString("cgimage"); |
| 214 | } |
skia.committer@gmail.com | ede0c5c | 2014-04-23 03:04:11 +0000 | [diff] [blame] | 215 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 216 | SkISize onISize() override { |
commit-bot@chromium.org | 60b5dce | 2014-04-22 20:24:33 +0000 | [diff] [blame] | 217 | return SkISize::Make(800, 250); |
| 218 | } |
skia.committer@gmail.com | ede0c5c | 2014-04-23 03:04:11 +0000 | [diff] [blame] | 219 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 220 | void onDraw(SkCanvas* canvas) override { |
commit-bot@chromium.org | 60b5dce | 2014-04-22 20:24:33 +0000 | [diff] [blame] | 221 | const struct { |
| 222 | SkColorType fCT; |
| 223 | SkAlphaType fAT; |
| 224 | } rec[] = { |
| 225 | { kRGB_565_SkColorType, kOpaque_SkAlphaType }, |
| 226 | |
| 227 | { kRGBA_8888_SkColorType, kPremul_SkAlphaType }, |
| 228 | { kRGBA_8888_SkColorType, kUnpremul_SkAlphaType }, |
| 229 | { kRGBA_8888_SkColorType, kOpaque_SkAlphaType }, |
| 230 | |
| 231 | { kBGRA_8888_SkColorType, kPremul_SkAlphaType }, |
| 232 | { kBGRA_8888_SkColorType, kUnpremul_SkAlphaType }, |
| 233 | { kBGRA_8888_SkColorType, kOpaque_SkAlphaType }, |
| 234 | }; |
skia.committer@gmail.com | ede0c5c | 2014-04-23 03:04:11 +0000 | [diff] [blame] | 235 | |
commit-bot@chromium.org | 60b5dce | 2014-04-22 20:24:33 +0000 | [diff] [blame] | 236 | for (size_t i = 0; i < SK_ARRAY_COUNT(rec); ++i) { |
| 237 | SkImageInfo info = SkImageInfo::Make(100, 100, rec[i].fCT, rec[i].fAT); |
| 238 | test_image(canvas, info); |
| 239 | canvas->translate(info.width() + 10, 0); |
| 240 | } |
| 241 | } |
skia.committer@gmail.com | ede0c5c | 2014-04-23 03:04:11 +0000 | [diff] [blame] | 242 | |
commit-bot@chromium.org | 60b5dce | 2014-04-22 20:24:33 +0000 | [diff] [blame] | 243 | private: |
| 244 | typedef skiagm::GM INHERITED; |
| 245 | }; |
| 246 | |
bsalomon@google.com | 2a9e3ad | 2014-04-23 18:05:36 +0000 | [diff] [blame] | 247 | #if 0 // Disabled pending fix from reed@ |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 248 | DEF_GM( return new CGImageGM; ) |
bsalomon@google.com | 2a9e3ad | 2014-04-23 18:05:36 +0000 | [diff] [blame] | 249 | #endif |
commit-bot@chromium.org | 60b5dce | 2014-04-22 20:24:33 +0000 | [diff] [blame] | 250 | #endif |
reed | 8f76cb9 | 2015-04-22 17:38:23 -0700 | [diff] [blame] | 251 | |
| 252 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 253 | |
halcanary | 6950de6 | 2015-11-07 05:29:00 -0800 | [diff] [blame] | 254 | // https://bug.skia.org/3716 |
reed | 8f76cb9 | 2015-04-22 17:38:23 -0700 | [diff] [blame] | 255 | class ClipCubicGM : public skiagm::GM { |
| 256 | const SkScalar W = 100; |
| 257 | const SkScalar H = 240; |
| 258 | |
| 259 | SkPath fVPath, fHPath; |
| 260 | public: |
| 261 | ClipCubicGM() { |
| 262 | fVPath.moveTo(W, 0); |
| 263 | fVPath.cubicTo(W, H-10, 0, 10, 0, H); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 264 | |
reed | 8f76cb9 | 2015-04-22 17:38:23 -0700 | [diff] [blame] | 265 | SkMatrix pivot; |
| 266 | pivot.setRotate(90, W/2, H/2); |
| 267 | fVPath.transform(pivot, &fHPath); |
| 268 | } |
| 269 | |
| 270 | protected: |
| 271 | SkString onShortName() override { |
| 272 | return SkString("clipcubic"); |
| 273 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 274 | |
reed | 8f76cb9 | 2015-04-22 17:38:23 -0700 | [diff] [blame] | 275 | SkISize onISize() override { |
| 276 | return SkISize::Make(400, 410); |
| 277 | } |
| 278 | |
| 279 | void doDraw(SkCanvas* canvas, const SkPath& path) { |
| 280 | SkPaint paint; |
| 281 | paint.setAntiAlias(true); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 282 | |
caryclark | 1259601 | 2015-07-29 05:27:47 -0700 | [diff] [blame] | 283 | paint.setColor(sk_tool_utils::color_to_565(0xFFCCCCCC)); |
reed | 8f76cb9 | 2015-04-22 17:38:23 -0700 | [diff] [blame] | 284 | canvas->drawPath(path, paint); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 285 | |
reed | 8f76cb9 | 2015-04-22 17:38:23 -0700 | [diff] [blame] | 286 | paint.setColor(SK_ColorRED); |
| 287 | paint.setStyle(SkPaint::kStroke_Style); |
| 288 | canvas->drawPath(path, paint); |
| 289 | } |
| 290 | |
| 291 | void drawAndClip(SkCanvas* canvas, const SkPath& path, SkScalar dx, SkScalar dy) { |
| 292 | SkAutoCanvasRestore acr(canvas, true); |
| 293 | |
| 294 | SkRect r = SkRect::MakeXYWH(0, H/4, W, H/2); |
| 295 | SkPaint paint; |
caryclark | 1259601 | 2015-07-29 05:27:47 -0700 | [diff] [blame] | 296 | paint.setColor(sk_tool_utils::color_to_565(0xFF8888FF)); |
reed | 8f76cb9 | 2015-04-22 17:38:23 -0700 | [diff] [blame] | 297 | |
| 298 | canvas->drawRect(r, paint); |
| 299 | this->doDraw(canvas, path); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 300 | |
reed | 8f76cb9 | 2015-04-22 17:38:23 -0700 | [diff] [blame] | 301 | canvas->translate(dx, dy); |
| 302 | |
| 303 | canvas->drawRect(r, paint); |
| 304 | canvas->clipRect(r); |
| 305 | this->doDraw(canvas, path); |
| 306 | } |
| 307 | |
| 308 | void onDraw(SkCanvas* canvas) override { |
| 309 | canvas->translate(80, 10); |
| 310 | this->drawAndClip(canvas, fVPath, 200, 0); |
| 311 | canvas->translate(0, 200); |
| 312 | this->drawAndClip(canvas, fHPath, 200, 0); |
| 313 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 314 | |
reed | 8f76cb9 | 2015-04-22 17:38:23 -0700 | [diff] [blame] | 315 | private: |
| 316 | typedef skiagm::GM INHERITED; |
| 317 | }; |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 318 | DEF_GM(return new ClipCubicGM;) |