| 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(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(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 SkNEW(ClipCubicGM); ) | 263 DEF_GM( return SkNEW(ClipCubicGM); ) |
| 264 | 264 |
| OLD | NEW |