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