Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: gm/ovals.cpp

Issue 1263553002: make pixelsnap textblob* etc gm portable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add more 565 compatibility Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gm/multipicturedraw.cpp ('k') | gm/pathinterior.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « gm/multipicturedraw.cpp ('k') | gm/pathinterior.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698