| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "gm.h" | 9 #include "gm.h" |
| 10 #include "SkTArray.h" | 10 #include "SkTArray.h" |
| 11 #include "SkRandom.h" | 11 #include "SkRandom.h" |
| 12 #include "SkMatrix.h" | 12 #include "SkMatrix.h" |
| 13 #include "SkBlurMaskFilter.h" | 13 #include "SkBlurMaskFilter.h" |
| 14 #include "SkGradientShader.h" | 14 #include "SkGradientShader.h" |
| 15 #include "SkBlurDrawLooper.h" | 15 #include "SkBlurDrawLooper.h" |
| 16 #include "SkRect.h" | 16 #include "SkRect.h" |
| 17 #include "SkRRect.h" | 17 #include "SkRRect.h" |
| 18 | 18 |
| 19 namespace skiagm { | 19 namespace skiagm { |
| 20 | 20 |
| 21 class RoundRectGM : public GM { | 21 class RoundRectGM : public GM { |
| 22 public: | 22 public: |
| 23 RoundRectGM() { | 23 RoundRectGM() { |
| 24 this->setBGColor(0xFF000000); | 24 this->setBGColor(0xFF000000); |
| 25 this->makePaints(); | 25 this->makePaints(); |
| 26 this->makeMatrices(); | 26 this->makeMatrices(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 protected: | 29 protected: |
| 30 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 30 uint32_t onGetFlags() const SK_OVERRIDE { |
| 31 return kSkipTiled_Flag; | 31 return kSkipTiled_Flag; |
| 32 } | 32 } |
| 33 | 33 |
| 34 virtual SkString onShortName() SK_OVERRIDE { | 34 SkString onShortName() SK_OVERRIDE { |
| 35 return SkString("roundrects"); | 35 return SkString("roundrects"); |
| 36 } | 36 } |
| 37 | 37 |
| 38 virtual SkISize onISize() SK_OVERRIDE { | 38 SkISize onISize() SK_OVERRIDE { |
| 39 return SkISize::Make(1200, 900); | 39 return SkISize::Make(1200, 900); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void makePaints() { | 42 void makePaints() { |
| 43 { | 43 { |
| 44 // no AA | 44 // no AA |
| 45 SkPaint p; | 45 SkPaint p; |
| 46 fPaints.push_back(p); | 46 fPaints.push_back(p); |
| 47 } | 47 } |
| 48 | 48 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 132 |
| 133 SkColor genColor(SkRandom* rand) { | 133 SkColor genColor(SkRandom* rand) { |
| 134 SkScalar hsv[3]; | 134 SkScalar hsv[3]; |
| 135 hsv[0] = rand->nextRangeF(0.0f, 360.0f); | 135 hsv[0] = rand->nextRangeF(0.0f, 360.0f); |
| 136 hsv[1] = rand->nextRangeF(0.75f, 1.0f); | 136 hsv[1] = rand->nextRangeF(0.75f, 1.0f); |
| 137 hsv[2] = rand->nextRangeF(0.75f, 1.0f); | 137 hsv[2] = rand->nextRangeF(0.75f, 1.0f); |
| 138 | 138 |
| 139 return SkHSVToColor(hsv); | 139 return SkHSVToColor(hsv); |
| 140 } | 140 } |
| 141 | 141 |
| 142 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 142 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 143 SkRandom rand(1); | 143 SkRandom rand(1); |
| 144 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); | 144 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); |
| 145 SkRect rect = SkRect::MakeLTRB(-20, -30, 20, 30); | 145 SkRect rect = SkRect::MakeLTRB(-20, -30, 20, 30); |
| 146 SkRRect circleRect; | 146 SkRRect circleRect; |
| 147 circleRect.setRectXY(rect, 5, 5); | 147 circleRect.setRectXY(rect, 5, 5); |
| 148 | 148 |
| 149 const SkScalar kXStart = 60.0f; | 149 const SkScalar kXStart = 60.0f; |
| 150 const SkScalar kYStart = 80.0f; | 150 const SkScalar kYStart = 80.0f; |
| 151 const int kXStep = 150; | 151 const int kXStep = 150; |
| 152 const int kYStep = 160; | 152 const int kYStep = 160; |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 334 |
| 335 typedef GM INHERITED; | 335 typedef GM INHERITED; |
| 336 }; | 336 }; |
| 337 | 337 |
| 338 ////////////////////////////////////////////////////////////////////////////// | 338 ////////////////////////////////////////////////////////////////////////////// |
| 339 | 339 |
| 340 static GM* MyFactory(void*) { return new RoundRectGM; } | 340 static GM* MyFactory(void*) { return new RoundRectGM; } |
| 341 static GMRegistry reg(MyFactory); | 341 static GMRegistry reg(MyFactory); |
| 342 | 342 |
| 343 } | 343 } |
| OLD | NEW |