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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 186 } |
187 | 187 |
188 private: | 188 private: |
189 typedef skiagm::GM INHERITED; | 189 typedef skiagm::GM INHERITED; |
190 }; | 190 }; |
191 | 191 |
192 #if 0 // Disabled pending fix from reed@ | 192 #if 0 // Disabled pending fix from reed@ |
193 DEF_GM( return SkNEW(CGImageGM); ) | 193 DEF_GM( return SkNEW(CGImageGM); ) |
194 #endif | 194 #endif |
195 #endif | 195 #endif |
| 196 |
| 197 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 198 |
| 199 // skbug.com/3716 |
| 200 class ClipCubicGM : public skiagm::GM { |
| 201 const SkScalar W = 100; |
| 202 const SkScalar H = 240; |
| 203 |
| 204 SkPath fVPath, fHPath; |
| 205 public: |
| 206 ClipCubicGM() { |
| 207 fVPath.moveTo(W, 0); |
| 208 fVPath.cubicTo(W, H-10, 0, 10, 0, H); |
| 209 |
| 210 SkMatrix pivot; |
| 211 pivot.setRotate(90, W/2, H/2); |
| 212 fVPath.transform(pivot, &fHPath); |
| 213 } |
| 214 |
| 215 protected: |
| 216 SkString onShortName() override { |
| 217 return SkString("clipcubic"); |
| 218 } |
| 219 |
| 220 SkISize onISize() override { |
| 221 return SkISize::Make(400, 410); |
| 222 } |
| 223 |
| 224 void doDraw(SkCanvas* canvas, const SkPath& path) { |
| 225 SkPaint paint; |
| 226 paint.setAntiAlias(true); |
| 227 |
| 228 paint.setColor(0xFFCCCCCC); |
| 229 canvas->drawPath(path, paint); |
| 230 |
| 231 paint.setColor(SK_ColorRED); |
| 232 paint.setStyle(SkPaint::kStroke_Style); |
| 233 canvas->drawPath(path, paint); |
| 234 } |
| 235 |
| 236 void drawAndClip(SkCanvas* canvas, const SkPath& path, SkScalar dx, SkScalar
dy) { |
| 237 SkAutoCanvasRestore acr(canvas, true); |
| 238 |
| 239 SkRect r = SkRect::MakeXYWH(0, H/4, W, H/2); |
| 240 SkPaint paint; |
| 241 paint.setColor(0xFF8888FF); |
| 242 |
| 243 canvas->drawRect(r, paint); |
| 244 this->doDraw(canvas, path); |
| 245 |
| 246 canvas->translate(dx, dy); |
| 247 |
| 248 canvas->drawRect(r, paint); |
| 249 canvas->clipRect(r); |
| 250 this->doDraw(canvas, path); |
| 251 } |
| 252 |
| 253 void onDraw(SkCanvas* canvas) override { |
| 254 canvas->translate(80, 10); |
| 255 this->drawAndClip(canvas, fVPath, 200, 0); |
| 256 canvas->translate(0, 200); |
| 257 this->drawAndClip(canvas, fHPath, 200, 0); |
| 258 } |
| 259 |
| 260 private: |
| 261 typedef skiagm::GM INHERITED; |
| 262 }; |
| 263 DEF_GM( return SkNEW(ClipCubicGM); ) |
| 264 |
OLD | NEW |