| 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 #include "gm.h" | 7 #include "gm.h" |
| 8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkPaint.h" | 9 #include "SkPaint.h" |
| 10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
| 11 | 11 |
| 12 namespace skiagm { | 12 namespace skiagm { |
| 13 | 13 |
| 14 class QuadPathGM : public GM { | 14 class QuadPathGM : public GM { |
| 15 public: | 15 public: |
| 16 QuadPathGM() {} | 16 QuadPathGM() {} |
| 17 | 17 |
| 18 protected: | 18 protected: |
| 19 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 19 uint32_t onGetFlags() const SK_OVERRIDE { |
| 20 return kSkipTiled_Flag; | 20 return kSkipTiled_Flag; |
| 21 } | 21 } |
| 22 | 22 |
| 23 SkString onShortName() SK_OVERRIDE { | 23 SkString onShortName() SK_OVERRIDE { |
| 24 return SkString("quadpath"); | 24 return SkString("quadpath"); |
| 25 } | 25 } |
| 26 | 26 |
| 27 SkISize onISize() SK_OVERRIDE { return SkISize::Make(1240, 390); } | 27 SkISize onISize() SK_OVERRIDE { return SkISize::Make(1240, 390); } |
| 28 | 28 |
| 29 void drawPath(SkPath& path,SkCanvas* canvas,SkColor color, | 29 void drawPath(SkPath& path,SkCanvas* canvas,SkColor color, |
| 30 const SkRect& clip,SkPaint::Cap cap, SkPaint::Join join, | 30 const SkRect& clip,SkPaint::Cap cap, SkPaint::Join join, |
| 31 SkPaint::Style style, SkPath::FillType fill, | 31 SkPaint::Style style, SkPath::FillType fill, |
| 32 SkScalar strokeWidth) { | 32 SkScalar strokeWidth) { |
| 33 path.setFillType(fill); | 33 path.setFillType(fill); |
| 34 SkPaint paint; | 34 SkPaint paint; |
| 35 paint.setStrokeCap(cap); | 35 paint.setStrokeCap(cap); |
| 36 paint.setStrokeWidth(strokeWidth); | 36 paint.setStrokeWidth(strokeWidth); |
| 37 paint.setStrokeJoin(join); | 37 paint.setStrokeJoin(join); |
| 38 paint.setColor(color); | 38 paint.setColor(color); |
| 39 paint.setStyle(style); | 39 paint.setStyle(style); |
| 40 canvas->save(); | 40 canvas->save(); |
| 41 canvas->clipRect(clip); | 41 canvas->clipRect(clip); |
| 42 canvas->drawPath(path, paint); | 42 canvas->drawPath(path, paint); |
| 43 canvas->restore(); | 43 canvas->restore(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 46 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 47 struct FillAndName { | 47 struct FillAndName { |
| 48 SkPath::FillType fFill; | 48 SkPath::FillType fFill; |
| 49 const char* fName; | 49 const char* fName; |
| 50 }; | 50 }; |
| 51 static const FillAndName gFills[] = { | 51 static const FillAndName gFills[] = { |
| 52 {SkPath::kWinding_FillType, "Winding"}, | 52 {SkPath::kWinding_FillType, "Winding"}, |
| 53 {SkPath::kEvenOdd_FillType, "Even / Odd"}, | 53 {SkPath::kEvenOdd_FillType, "Even / Odd"}, |
| 54 {SkPath::kInverseWinding_FillType, "Inverse Winding"}, | 54 {SkPath::kInverseWinding_FillType, "Inverse Winding"}, |
| 55 {SkPath::kInverseEvenOdd_FillType, "Inverse Even / Odd"}, | 55 {SkPath::kInverseEvenOdd_FillType, "Inverse Even / Odd"}, |
| 56 }; | 56 }; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 private: | 158 private: |
| 159 typedef GM INHERITED; | 159 typedef GM INHERITED; |
| 160 }; | 160 }; |
| 161 | 161 |
| 162 class QuadClosePathGM : public GM { | 162 class QuadClosePathGM : public GM { |
| 163 public: | 163 public: |
| 164 QuadClosePathGM() {} | 164 QuadClosePathGM() {} |
| 165 | 165 |
| 166 protected: | 166 protected: |
| 167 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 167 uint32_t onGetFlags() const SK_OVERRIDE { |
| 168 return kSkipTiled_Flag; | 168 return kSkipTiled_Flag; |
| 169 } | 169 } |
| 170 | 170 |
| 171 SkString onShortName() SK_OVERRIDE { | 171 SkString onShortName() SK_OVERRIDE { |
| 172 return SkString("quadclosepath"); | 172 return SkString("quadclosepath"); |
| 173 } | 173 } |
| 174 | 174 |
| 175 SkISize onISize() SK_OVERRIDE { return SkISize::Make(1240, 390); } | 175 SkISize onISize() SK_OVERRIDE { return SkISize::Make(1240, 390); } |
| 176 | 176 |
| 177 void drawPath(SkPath& path,SkCanvas* canvas,SkColor color, | 177 void drawPath(SkPath& path,SkCanvas* canvas,SkColor color, |
| 178 const SkRect& clip,SkPaint::Cap cap, SkPaint::Join join, | 178 const SkRect& clip,SkPaint::Cap cap, SkPaint::Join join, |
| 179 SkPaint::Style style, SkPath::FillType fill, | 179 SkPaint::Style style, SkPath::FillType fill, |
| 180 SkScalar strokeWidth) { | 180 SkScalar strokeWidth) { |
| 181 path.setFillType(fill); | 181 path.setFillType(fill); |
| 182 SkPaint paint; | 182 SkPaint paint; |
| 183 paint.setStrokeCap(cap); | 183 paint.setStrokeCap(cap); |
| 184 paint.setStrokeWidth(strokeWidth); | 184 paint.setStrokeWidth(strokeWidth); |
| 185 paint.setStrokeJoin(join); | 185 paint.setStrokeJoin(join); |
| 186 paint.setColor(color); | 186 paint.setColor(color); |
| 187 paint.setStyle(style); | 187 paint.setStyle(style); |
| 188 canvas->save(); | 188 canvas->save(); |
| 189 canvas->clipRect(clip); | 189 canvas->clipRect(clip); |
| 190 canvas->drawPath(path, paint); | 190 canvas->drawPath(path, paint); |
| 191 canvas->restore(); | 191 canvas->restore(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 194 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 195 struct FillAndName { | 195 struct FillAndName { |
| 196 SkPath::FillType fFill; | 196 SkPath::FillType fFill; |
| 197 const char* fName; | 197 const char* fName; |
| 198 }; | 198 }; |
| 199 static const FillAndName gFills[] = { | 199 static const FillAndName gFills[] = { |
| 200 {SkPath::kWinding_FillType, "Winding"}, | 200 {SkPath::kWinding_FillType, "Winding"}, |
| 201 {SkPath::kEvenOdd_FillType, "Even / Odd"}, | 201 {SkPath::kEvenOdd_FillType, "Even / Odd"}, |
| 202 {SkPath::kInverseWinding_FillType, "Inverse Winding"}, | 202 {SkPath::kInverseWinding_FillType, "Inverse Winding"}, |
| 203 {SkPath::kInverseEvenOdd_FillType, "Inverse Even / Odd"}, | 203 {SkPath::kInverseEvenOdd_FillType, "Inverse Even / Odd"}, |
| 204 }; | 204 }; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 310 |
| 311 ////////////////////////////////////////////////////////////////////////////// | 311 ////////////////////////////////////////////////////////////////////////////// |
| 312 | 312 |
| 313 static GM* QuadPathFactory(void*) { return new QuadPathGM; } | 313 static GM* QuadPathFactory(void*) { return new QuadPathGM; } |
| 314 static GMRegistry regQuadPath(QuadPathFactory); | 314 static GMRegistry regQuadPath(QuadPathFactory); |
| 315 | 315 |
| 316 static GM* QuadClosePathFactory(void*) { return new QuadClosePathGM; } | 316 static GM* QuadClosePathFactory(void*) { return new QuadClosePathGM; } |
| 317 static GMRegistry regQuadClosePath(QuadClosePathFactory); | 317 static GMRegistry regQuadClosePath(QuadClosePathFactory); |
| 318 | 318 |
| 319 } | 319 } |
| OLD | NEW |