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

Side by Side Diff: gm/hairlines.cpp

Issue 23532082: Add GM case for arc truncation error bug (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Added suppression Created 7 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 | Annotate | Revision Log
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | no next file » | 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 2013 Google Inc. 2 * Copyright 2013 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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkTArray.h" 10 #include "SkTArray.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 127
128 { 128 {
129 // A right angle (crbug.com/137465 and crbug.com/256776) 129 // A right angle (crbug.com/137465 and crbug.com/256776)
130 SkPath* bug2 = &fPaths.push_back(); 130 SkPath* bug2 = &fPaths.push_back();
131 131
132 bug2->moveTo(5.5f, 5.5f); 132 bug2->moveTo(5.5f, 5.5f);
133 bug2->lineTo(5.5f, 0.5f); 133 bug2->lineTo(5.5f, 0.5f);
134 bug2->lineTo(0.5f, 0.5f); 134 bug2->lineTo(0.5f, 0.5f);
135 } 135 }
136
137 {
138 // Arc example to test imperfect truncation bug (crbug.com/295626)
139 static const SkScalar kRad = SkIntToScalar(2000);
140 static const SkScalar kStartAngle = SkFloatToScalar(262.59717f);
141 static const SkScalar kSweepAngle = SkScalarHalf(SkFloatToScalar(17. 188717f));
142
143 SkPath* bug = &fPaths.push_back();
144
145 // Add a circular arc
146 SkRect circle = SkRect::MakeLTRB(-kRad, -kRad, kRad, kRad);
147 bug->addArc(circle, kStartAngle, kSweepAngle);
148
149 // Now add the chord that should cap the circular arc
150 SkScalar cosV, sinV = SkScalarSinCos(SkDegreesToRadians(kStartAngle) , &cosV);
151
152 SkPoint p0 = SkPoint::Make(kRad * cosV, kRad * sinV);
153
154 sinV = SkScalarSinCos(SkDegreesToRadians(kStartAngle + kSweepAngle), &cosV);
155
156 SkPoint p1 = SkPoint::Make(kRad * cosV, kRad * sinV);
157
158 bug->moveTo(p0);
159 bug->lineTo(p1);
160 }
136 } 161 }
137 162
138 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 163 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
139 static const SkAlpha kAlphaValue[] = { 0xFF, 0x40 }; 164 static const SkAlpha kAlphaValue[] = { 0xFF, 0x40 };
140 165
141 enum { 166 enum {
142 kMargin = 5, 167 kMargin = 5,
143 }; 168 };
144 int wrapX = canvas->getDeviceSize().fWidth - kMargin; 169 int wrapX = canvas->getDeviceSize().fWidth - kMargin;
145 170
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 SkTArray<SkPath> fPaths; 212 SkTArray<SkPath> fPaths;
188 typedef GM INHERITED; 213 typedef GM INHERITED;
189 }; 214 };
190 215
191 ////////////////////////////////////////////////////////////////////////////// 216 //////////////////////////////////////////////////////////////////////////////
192 217
193 static GM* MyFactory(void*) { return new HairlinesGM; } 218 static GM* MyFactory(void*) { return new HairlinesGM; }
194 static GMRegistry reg(MyFactory); 219 static GMRegistry reg(MyFactory);
195 220
196 } 221 }
OLDNEW
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698