OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 #ifndef SkGeometry_DEFINED | 8 #ifndef SkGeometry_DEFINED |
9 #define SkGeometry_DEFINED | 9 #define SkGeometry_DEFINED |
10 | 10 |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 /** | 228 /** |
229 * return the power-of-2 number of quads needed to approximate this conic | 229 * return the power-of-2 number of quads needed to approximate this conic |
230 * with a sequence of quads. Will be >= 0. | 230 * with a sequence of quads. Will be >= 0. |
231 */ | 231 */ |
232 int computeQuadPOW2(SkScalar tol) const; | 232 int computeQuadPOW2(SkScalar tol) const; |
233 | 233 |
234 /** | 234 /** |
235 * Chop this conic into N quads, stored continguously in pts[], where | 235 * Chop this conic into N quads, stored continguously in pts[], where |
236 * N = 1 << pow2. The amount of storage needed is (1 + 2 * N) | 236 * N = 1 << pow2. The amount of storage needed is (1 + 2 * N) |
237 */ | 237 */ |
238 int chopIntoQuadsPOW2(SkPoint pts[], int pow2) const; | 238 int SK_WARN_UNUSED_RESULT chopIntoQuadsPOW2(SkPoint pts[], int pow2) const; |
239 | 239 |
240 bool findXExtrema(SkScalar* t) const; | 240 bool findXExtrema(SkScalar* t) const; |
241 bool findYExtrema(SkScalar* t) const; | 241 bool findYExtrema(SkScalar* t) const; |
242 bool chopAtXExtrema(SkConic dst[2]) const; | 242 bool chopAtXExtrema(SkConic dst[2]) const; |
243 bool chopAtYExtrema(SkConic dst[2]) const; | 243 bool chopAtYExtrema(SkConic dst[2]) const; |
244 | 244 |
245 void computeTightBounds(SkRect* bounds) const; | 245 void computeTightBounds(SkRect* bounds) const; |
246 void computeFastBounds(SkRect* bounds) const; | 246 void computeFastBounds(SkRect* bounds) const; |
247 | 247 |
248 /** Find the parameter value where the conic takes on its maximum curvature. | 248 /** Find the parameter value where the conic takes on its maximum curvature. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 * there will be 9 points allocated as follows | 377 * there will be 9 points allocated as follows |
378 * quad[0] == pts[0..2] | 378 * quad[0] == pts[0..2] |
379 * quad[1] == pts[2..4] | 379 * quad[1] == pts[2..4] |
380 * quad[2] == pts[4..6] | 380 * quad[2] == pts[4..6] |
381 * quad[3] == pts[6..8] | 381 * quad[3] == pts[6..8] |
382 */ | 382 */ |
383 const SkPoint* computeQuads(const SkConic& conic, SkScalar tol) { | 383 const SkPoint* computeQuads(const SkConic& conic, SkScalar tol) { |
384 int pow2 = conic.computeQuadPOW2(tol); | 384 int pow2 = conic.computeQuadPOW2(tol); |
385 fQuadCount = 1 << pow2; | 385 fQuadCount = 1 << pow2; |
386 SkPoint* pts = fStorage.reset(1 + 2 * fQuadCount); | 386 SkPoint* pts = fStorage.reset(1 + 2 * fQuadCount); |
387 conic.chopIntoQuadsPOW2(pts, pow2); | 387 fQuadCount = conic.chopIntoQuadsPOW2(pts, pow2); |
388 return pts; | 388 return pts; |
389 } | 389 } |
390 | 390 |
391 const SkPoint* computeQuads(const SkPoint pts[3], SkScalar weight, | 391 const SkPoint* computeQuads(const SkPoint pts[3], SkScalar weight, |
392 SkScalar tol) { | 392 SkScalar tol) { |
393 SkConic conic; | 393 SkConic conic; |
394 conic.set(pts, weight); | 394 conic.set(pts, weight); |
395 return computeQuads(conic, tol); | 395 return computeQuads(conic, tol); |
396 } | 396 } |
397 | 397 |
398 int countQuads() const { return fQuadCount; } | 398 int countQuads() const { return fQuadCount; } |
399 | 399 |
400 private: | 400 private: |
401 enum { | 401 enum { |
402 kQuadCount = 8, // should handle most conics | 402 kQuadCount = 8, // should handle most conics |
403 kPointCount = 1 + 2 * kQuadCount, | 403 kPointCount = 1 + 2 * kQuadCount, |
404 }; | 404 }; |
405 SkAutoSTMalloc<kPointCount, SkPoint> fStorage; | 405 SkAutoSTMalloc<kPointCount, SkPoint> fStorage; |
406 int fQuadCount; // #quads for current usage | 406 int fQuadCount; // #quads for current usage |
407 }; | 407 }; |
408 | 408 |
409 #endif | 409 #endif |
OLD | NEW |