| 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" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 fMatrices.push_back(m); | 126 fMatrices.push_back(m); |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 SkColor genColor(SkRandom* rand) { | 130 SkColor genColor(SkRandom* rand) { |
| 131 SkScalar hsv[3]; | 131 SkScalar hsv[3]; |
| 132 hsv[0] = rand->nextRangeF(0.0f, 360.0f); | 132 hsv[0] = rand->nextRangeF(0.0f, 360.0f); |
| 133 hsv[1] = rand->nextRangeF(0.75f, 1.0f); | 133 hsv[1] = rand->nextRangeF(0.75f, 1.0f); |
| 134 hsv[2] = rand->nextRangeF(0.75f, 1.0f); | 134 hsv[2] = rand->nextRangeF(0.75f, 1.0f); |
| 135 | 135 |
| 136 return SkHSVToColor(hsv); | 136 return sk_tool_utils::color_to_565(SkHSVToColor(hsv)); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void onDraw(SkCanvas* canvas) override { | 139 void onDraw(SkCanvas* canvas) override { |
| 140 SkRandom rand(1); | 140 SkRandom rand(1); |
| 141 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); | 141 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); |
| 142 SkRect rect = SkRect::MakeLTRB(-20, -30, 20, 30); | 142 SkRect rect = SkRect::MakeLTRB(-20, -30, 20, 30); |
| 143 SkRRect circleRect; | 143 SkRRect circleRect; |
| 144 circleRect.setRectXY(rect, 5, 5); | 144 circleRect.setRectXY(rect, 5, 5); |
| 145 | 145 |
| 146 const SkScalar kXStart = 60.0f; | 146 const SkScalar kXStart = 60.0f; |
| 147 const SkScalar kYStart = 80.0f; | 147 const SkScalar kYStart = 80.0f; |
| 148 const int kXStep = 150; | 148 const int kXStep = 150; |
| 149 const int kYStep = 160; | 149 const int kYStep = 160; |
| 150 int maxX = fMatrices.count(); | 150 int maxX = fMatrices.count(); |
| 151 | 151 |
| 152 SkPaint rectPaint; | 152 SkPaint rectPaint; |
| 153 rectPaint.setAntiAlias(true); | 153 rectPaint.setAntiAlias(true); |
| 154 rectPaint.setStyle(SkPaint::kStroke_Style); | 154 rectPaint.setStyle(SkPaint::kStroke_Style); |
| 155 rectPaint.setStrokeWidth(SkIntToScalar(0)); | 155 rectPaint.setStrokeWidth(SkIntToScalar(0)); |
| 156 rectPaint.setColor(SK_ColorLTGRAY); | 156 rectPaint.setColor(sk_tool_utils::color_to_565(SK_ColorLTGRAY)); |
| 157 | 157 |
| 158 int testCount = 0; | 158 int testCount = 0; |
| 159 for (int i = 0; i < fPaints.count(); ++i) { | 159 for (int i = 0; i < fPaints.count(); ++i) { |
| 160 for (int j = 0; j < fMatrices.count(); ++j) { | 160 for (int j = 0; j < fMatrices.count(); ++j) { |
| 161 canvas->save(); | 161 canvas->save(); |
| 162 SkMatrix mat = fMatrices[j]; | 162 SkMatrix mat = fMatrices[j]; |
| 163 // position the roundrect, and make it at off-integer coords. | 163 // position the roundrect, and make it at off-integer coords. |
| 164 mat.postTranslate(kXStart + SK_Scalar1 * kXStep * (testCount % m
axX) + | 164 mat.postTranslate(kXStart + SK_Scalar1 * kXStep * (testCount % m
axX) + |
| 165 SK_Scalar1 / 4, | 165 SK_Scalar1 / 4, |
| 166 kYStart + SK_Scalar1 * kYStep * (testCount / m
axX) + | 166 kYStart + SK_Scalar1 * kYStep * (testCount / m
axX) + |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 331 |
| 332 typedef GM INHERITED; | 332 typedef GM INHERITED; |
| 333 }; | 333 }; |
| 334 | 334 |
| 335 ////////////////////////////////////////////////////////////////////////////// | 335 ////////////////////////////////////////////////////////////////////////////// |
| 336 | 336 |
| 337 static GM* MyFactory(void*) { return new RoundRectGM; } | 337 static GM* MyFactory(void*) { return new RoundRectGM; } |
| 338 static GMRegistry reg(MyFactory); | 338 static GMRegistry reg(MyFactory); |
| 339 | 339 |
| 340 } | 340 } |
| OLD | NEW |