| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkPath.h" | 10 #include "SkPath.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 // https://bug.skia.org/3716 | 199 // https://bug.skia.org/3716 |
| 200 class ClipCubicGM : public skiagm::GM { | 200 class ClipCubicGM : public skiagm::GM { |
| 201 const SkScalar W = 100; | 201 const SkScalar W = 100; |
| 202 const SkScalar H = 240; | 202 const SkScalar H = 240; |
| 203 | 203 |
| 204 SkPath fVPath, fHPath; | 204 SkPath fVPath, fHPath; |
| 205 public: | 205 public: |
| 206 ClipCubicGM() { | 206 ClipCubicGM() { |
| 207 fVPath.moveTo(W, 0); | 207 fVPath.moveTo(W, 0); |
| 208 fVPath.cubicTo(W, H-10, 0, 10, 0, H); | 208 fVPath.cubicTo(W, H-10, 0, 10, 0, H); |
| 209 | 209 |
| 210 SkMatrix pivot; | 210 SkMatrix pivot; |
| 211 pivot.setRotate(90, W/2, H/2); | 211 pivot.setRotate(90, W/2, H/2); |
| 212 fVPath.transform(pivot, &fHPath); | 212 fVPath.transform(pivot, &fHPath); |
| 213 } | 213 } |
| 214 | 214 |
| 215 protected: | 215 protected: |
| 216 SkString onShortName() override { | 216 SkString onShortName() override { |
| 217 return SkString("clipcubic"); | 217 return SkString("clipcubic"); |
| 218 } | 218 } |
| 219 | 219 |
| 220 SkISize onISize() override { | 220 SkISize onISize() override { |
| 221 return SkISize::Make(400, 410); | 221 return SkISize::Make(400, 410); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void doDraw(SkCanvas* canvas, const SkPath& path) { | 224 void doDraw(SkCanvas* canvas, const SkPath& path) { |
| 225 SkPaint paint; | 225 SkPaint paint; |
| 226 paint.setAntiAlias(true); | 226 paint.setAntiAlias(true); |
| 227 | 227 |
| 228 paint.setColor(sk_tool_utils::color_to_565(0xFFCCCCCC)); | 228 paint.setColor(sk_tool_utils::color_to_565(0xFFCCCCCC)); |
| 229 canvas->drawPath(path, paint); | 229 canvas->drawPath(path, paint); |
| 230 | 230 |
| 231 paint.setColor(SK_ColorRED); | 231 paint.setColor(SK_ColorRED); |
| 232 paint.setStyle(SkPaint::kStroke_Style); | 232 paint.setStyle(SkPaint::kStroke_Style); |
| 233 canvas->drawPath(path, paint); | 233 canvas->drawPath(path, paint); |
| 234 } | 234 } |
| 235 | 235 |
| 236 void drawAndClip(SkCanvas* canvas, const SkPath& path, SkScalar dx, SkScalar
dy) { | 236 void drawAndClip(SkCanvas* canvas, const SkPath& path, SkScalar dx, SkScalar
dy) { |
| 237 SkAutoCanvasRestore acr(canvas, true); | 237 SkAutoCanvasRestore acr(canvas, true); |
| 238 | 238 |
| 239 SkRect r = SkRect::MakeXYWH(0, H/4, W, H/2); | 239 SkRect r = SkRect::MakeXYWH(0, H/4, W, H/2); |
| 240 SkPaint paint; | 240 SkPaint paint; |
| 241 paint.setColor(sk_tool_utils::color_to_565(0xFF8888FF)); | 241 paint.setColor(sk_tool_utils::color_to_565(0xFF8888FF)); |
| 242 | 242 |
| 243 canvas->drawRect(r, paint); | 243 canvas->drawRect(r, paint); |
| 244 this->doDraw(canvas, path); | 244 this->doDraw(canvas, path); |
| 245 | 245 |
| 246 canvas->translate(dx, dy); | 246 canvas->translate(dx, dy); |
| 247 | 247 |
| 248 canvas->drawRect(r, paint); | 248 canvas->drawRect(r, paint); |
| 249 canvas->clipRect(r); | 249 canvas->clipRect(r); |
| 250 this->doDraw(canvas, path); | 250 this->doDraw(canvas, path); |
| 251 } | 251 } |
| 252 | 252 |
| 253 void onDraw(SkCanvas* canvas) override { | 253 void onDraw(SkCanvas* canvas) override { |
| 254 canvas->translate(80, 10); | 254 canvas->translate(80, 10); |
| 255 this->drawAndClip(canvas, fVPath, 200, 0); | 255 this->drawAndClip(canvas, fVPath, 200, 0); |
| 256 canvas->translate(0, 200); | 256 canvas->translate(0, 200); |
| 257 this->drawAndClip(canvas, fHPath, 200, 0); | 257 this->drawAndClip(canvas, fHPath, 200, 0); |
| 258 } | 258 } |
| 259 | 259 |
| 260 private: | 260 private: |
| 261 typedef skiagm::GM INHERITED; | 261 typedef skiagm::GM INHERITED; |
| 262 }; | 262 }; |
| 263 DEF_GM(return new ClipCubicGM;) | 263 DEF_GM(return new ClipCubicGM;) |
| OLD | NEW |