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

Side by Side Diff: src/core/SkGeometry.h

Issue 892703002: use conics for arcTo (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix the legacy code-path for chrome Created 5 years, 10 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/SkGeometry.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 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
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 9
10 #ifndef SkGeometry_DEFINED 10 #ifndef SkGeometry_DEFINED
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 219
220 /** Given 2 unit vectors and a rotation direction, fill out the specified 220 /** Given 2 unit vectors and a rotation direction, fill out the specified
221 array of points with quadratic segments. Return is the number of points 221 array of points with quadratic segments. Return is the number of points
222 written to, which will be { 0, 3, 5, 7, ... kSkBuildQuadArcStorage } 222 written to, which will be { 0, 3, 5, 7, ... kSkBuildQuadArcStorage }
223 223
224 matrix, if not null, is appled to the points before they are returned. 224 matrix, if not null, is appled to the points before they are returned.
225 */ 225 */
226 int SkBuildQuadArc(const SkVector& unitStart, const SkVector& unitStop, 226 int SkBuildQuadArc(const SkVector& unitStart, const SkVector& unitStop,
227 SkRotationDirection, const SkMatrix*, SkPoint quadPoints[]); 227 SkRotationDirection, const SkMatrix*, SkPoint quadPoints[]);
228 228
229 // experimental
230 struct SkConic { 229 struct SkConic {
231 SkConic() {} 230 SkConic() {}
232 SkConic(const SkPoint& p0, const SkPoint& p1, const SkPoint& p2, SkScalar w) { 231 SkConic(const SkPoint& p0, const SkPoint& p1, const SkPoint& p2, SkScalar w) {
233 fPts[0] = p0; 232 fPts[0] = p0;
234 fPts[1] = p1; 233 fPts[1] = p1;
235 fPts[2] = p2; 234 fPts[2] = p2;
236 fW = w; 235 fW = w;
237 } 236 }
238 SkConic(const SkPoint pts[3], SkScalar w) { 237 SkConic(const SkPoint pts[3], SkScalar w) {
239 memcpy(fPts, pts, sizeof(fPts)); 238 memcpy(fPts, pts, sizeof(fPts));
240 fW = w; 239 fW = w;
241 } 240 }
242 241
243 SkPoint fPts[3]; 242 SkPoint fPts[3];
244 SkScalar fW; 243 SkScalar fW;
245 244
246 void set(const SkPoint pts[3], SkScalar w) { 245 void set(const SkPoint pts[3], SkScalar w) {
247 memcpy(fPts, pts, 3 * sizeof(SkPoint)); 246 memcpy(fPts, pts, 3 * sizeof(SkPoint));
248 fW = w; 247 fW = w;
249 } 248 }
250 249
250 void set(const SkPoint& p0, const SkPoint& p1, const SkPoint& p2, SkScalar w ) {
251 fPts[0] = p0;
252 fPts[1] = p1;
253 fPts[2] = p2;
254 fW = w;
255 }
256
251 /** 257 /**
252 * Given a t-value [0...1] return its position and/or tangent. 258 * Given a t-value [0...1] return its position and/or tangent.
253 * If pos is not null, return its position at the t-value. 259 * If pos is not null, return its position at the t-value.
254 * If tangent is not null, return its tangent at the t-value. NOTE the 260 * If tangent is not null, return its tangent at the t-value. NOTE the
255 * tangent value's length is arbitrary, and only its direction should 261 * tangent value's length is arbitrary, and only its direction should
256 * be used. 262 * be used.
257 */ 263 */
258 void evalAt(SkScalar t, SkPoint* pos, SkVector* tangent = NULL) const; 264 void evalAt(SkScalar t, SkPoint* pos, SkVector* tangent = NULL) const;
259 void chopAt(SkScalar t, SkConic dst[2]) const; 265 void chopAt(SkScalar t, SkConic dst[2]) const;
260 void chop(SkConic dst[2]) const; 266 void chop(SkConic dst[2]) const;
(...skipping 24 matching lines...) Expand all
285 /** Find the parameter value where the conic takes on its maximum curvature. 291 /** Find the parameter value where the conic takes on its maximum curvature.
286 * 292 *
287 * @param t output scalar for max curvature. Will be unchanged if 293 * @param t output scalar for max curvature. Will be unchanged if
288 * max curvature outside 0..1 range. 294 * max curvature outside 0..1 range.
289 * 295 *
290 * @return true if max curvature found inside 0..1 range, false otherwise 296 * @return true if max curvature found inside 0..1 range, false otherwise
291 */ 297 */
292 bool findMaxCurvature(SkScalar* t) const; 298 bool findMaxCurvature(SkScalar* t) const;
293 299
294 static SkScalar TransformW(const SkPoint[3], SkScalar w, const SkMatrix&); 300 static SkScalar TransformW(const SkPoint[3], SkScalar w, const SkMatrix&);
301
302 enum {
303 kMaxConicsForArc = 5
304 };
305 static int BuildUnitArc(const SkVector& start, const SkVector& stop, SkRotat ionDirection,
306 const SkMatrix*, SkConic conics[kMaxConicsForArc]);
295 }; 307 };
296 308
297 #include "SkTemplates.h" 309 #include "SkTemplates.h"
298 310
299 /** 311 /**
300 * Help class to allocate storage for approximating a conic with N quads. 312 * Help class to allocate storage for approximating a conic with N quads.
301 */ 313 */
302 class SkAutoConicToQuads { 314 class SkAutoConicToQuads {
303 public: 315 public:
304 SkAutoConicToQuads() : fQuadCount(0) {} 316 SkAutoConicToQuads() : fQuadCount(0) {}
(...skipping 30 matching lines...) Expand all
335 private: 347 private:
336 enum { 348 enum {
337 kQuadCount = 8, // should handle most conics 349 kQuadCount = 8, // should handle most conics
338 kPointCount = 1 + 2 * kQuadCount, 350 kPointCount = 1 + 2 * kQuadCount,
339 }; 351 };
340 SkAutoSTMalloc<kPointCount, SkPoint> fStorage; 352 SkAutoSTMalloc<kPointCount, SkPoint> fStorage;
341 int fQuadCount; // #quads for current usage 353 int fQuadCount; // #quads for current usage
342 }; 354 };
343 355
344 #endif 356 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkGeometry.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698