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

Side by Side Diff: gm/strokes.cpp

Issue 1418133007: fix for teeny strokes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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 | « no previous file | src/core/SkStroke.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 * 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 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkPath.h" 9 #include "SkPath.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 canvas->translate(0, 30); 151 canvas->translate(0, 30);
152 canvas->drawPath(fLinePath, strokePaint); 152 canvas->drawPath(fLinePath, strokePaint);
153 canvas->restore(); 153 canvas->restore();
154 } 154 }
155 } 155 }
156 156
157 private: 157 private:
158 typedef skiagm::GM INHERITED; 158 typedef skiagm::GM INHERITED;
159 }; 159 };
160 160
161 class TeenyStrokesGM : public skiagm::GM {
162
163 SkString onShortName() override {
164 return SkString("teenyStrokes");
165 }
166
167 SkISize onISize() override {
168 return SkISize::Make(W, H*2);
169 }
170
171 static void line(SkScalar scale, SkCanvas* canvas, SkColor color) {
172 SkPaint p;
173 p.setAntiAlias(true);
174 p.setStyle(SkPaint::kStroke_Style);
175 p.setColor(color);
176 canvas->translate(50, 0);
177 canvas->save();
178 p.setStrokeWidth(scale * 5);
179 canvas->scale(1 / scale, 1 / scale);
180 canvas->drawLine(20 * scale, 20 * scale, 20 * scale, 100 * scale, p);
181 canvas->drawLine(20 * scale, 20 * scale, 100 * scale, 100 * scale, p);
182 canvas->restore();
183 }
184
185 void onDraw(SkCanvas* canvas) override {
186 line(0.00005f, canvas, SK_ColorBLACK);
187 line(0.000045f, canvas, SK_ColorRED);
188 line(0.0000035f, canvas, SK_ColorGREEN);
189 line(0.000003f, canvas, SK_ColorBLUE);
190 line(0.000002f, canvas, SK_ColorBLACK);
191 }
192 private:
193 typedef skiagm::GM INHERITED;
194 };
195
196
161 class Strokes2GM : public skiagm::GM { 197 class Strokes2GM : public skiagm::GM {
162 SkPath fPath; 198 SkPath fPath;
163 protected: 199 protected:
164 void onOnceBeforeDraw() override { 200 void onOnceBeforeDraw() override {
165 SkRandom rand; 201 SkRandom rand;
166 fPath.moveTo(0, 0); 202 fPath.moveTo(0, 0);
167 for (int i = 0; i < 13; i++) { 203 for (int i = 0; i < 13; i++) {
168 SkScalar x = rand.nextUScalar1() * (W >> 1); 204 SkScalar x = rand.nextUScalar1() * (W >> 1);
169 SkScalar y = rand.nextUScalar1() * (H >> 1); 205 SkScalar y = rand.nextUScalar1() * (H >> 1);
170 fPath.lineTo(x, y); 206 fPath.lineTo(x, y);
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 static skiagm::GM* F3(void*) { return new Strokes4GM; } 447 static skiagm::GM* F3(void*) { return new Strokes4GM; }
412 static skiagm::GM* F4(void*) { return new Strokes5GM; } 448 static skiagm::GM* F4(void*) { return new Strokes5GM; }
413 449
414 static skiagm::GMRegistry R0(F0); 450 static skiagm::GMRegistry R0(F0);
415 static skiagm::GMRegistry R1(F1); 451 static skiagm::GMRegistry R1(F1);
416 static skiagm::GMRegistry R2(F2); 452 static skiagm::GMRegistry R2(F2);
417 static skiagm::GMRegistry R3(F3); 453 static skiagm::GMRegistry R3(F3);
418 static skiagm::GMRegistry R4(F4); 454 static skiagm::GMRegistry R4(F4);
419 455
420 DEF_GM( return new ZeroLenStrokesGM; ) 456 DEF_GM( return new ZeroLenStrokesGM; )
457 DEF_GM( return new TeenyStrokesGM; )
OLDNEW
« no previous file with comments | « no previous file | src/core/SkStroke.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698