OLD | NEW |
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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 229 // experimental |
230 struct SkConic { | 230 struct SkConic { |
| 231 SkConic() {} |
| 232 SkConic(const SkPoint& p0, const SkPoint& p1, const SkPoint& p2, SkScalar w)
{ |
| 233 fPts[0] = p0; |
| 234 fPts[1] = p1; |
| 235 fPts[2] = p2; |
| 236 fW = w; |
| 237 } |
| 238 SkConic(const SkPoint pts[3], SkScalar w) { |
| 239 memcpy(fPts, pts, sizeof(fPts)); |
| 240 fW = w; |
| 241 } |
| 242 |
231 SkPoint fPts[3]; | 243 SkPoint fPts[3]; |
232 SkScalar fW; | 244 SkScalar fW; |
233 | 245 |
234 void set(const SkPoint pts[3], SkScalar w) { | 246 void set(const SkPoint pts[3], SkScalar w) { |
235 memcpy(fPts, pts, 3 * sizeof(SkPoint)); | 247 memcpy(fPts, pts, 3 * sizeof(SkPoint)); |
236 fW = w; | 248 fW = w; |
237 } | 249 } |
238 | 250 |
239 /** | 251 /** |
240 * Given a t-value [0...1] return its position and/or tangent. | 252 * Given a t-value [0...1] return its position and/or tangent. |
(...skipping 30 matching lines...) Expand all Loading... |
271 void computeFastBounds(SkRect* bounds) const; | 283 void computeFastBounds(SkRect* bounds) const; |
272 | 284 |
273 /** Find the parameter value where the conic takes on its maximum curvature. | 285 /** Find the parameter value where the conic takes on its maximum curvature. |
274 * | 286 * |
275 * @param t output scalar for max curvature. Will be unchanged if | 287 * @param t output scalar for max curvature. Will be unchanged if |
276 * max curvature outside 0..1 range. | 288 * max curvature outside 0..1 range. |
277 * | 289 * |
278 * @return true if max curvature found inside 0..1 range, false otherwise | 290 * @return true if max curvature found inside 0..1 range, false otherwise |
279 */ | 291 */ |
280 bool findMaxCurvature(SkScalar* t) const; | 292 bool findMaxCurvature(SkScalar* t) const; |
| 293 |
| 294 static SkScalar TransformW(const SkPoint[3], SkScalar w, const SkMatrix&); |
281 }; | 295 }; |
282 | 296 |
283 #include "SkTemplates.h" | 297 #include "SkTemplates.h" |
284 | 298 |
285 /** | 299 /** |
286 * Help class to allocate storage for approximating a conic with N quads. | 300 * Help class to allocate storage for approximating a conic with N quads. |
287 */ | 301 */ |
288 class SkAutoConicToQuads { | 302 class SkAutoConicToQuads { |
289 public: | 303 public: |
290 SkAutoConicToQuads() : fQuadCount(0) {} | 304 SkAutoConicToQuads() : fQuadCount(0) {} |
(...skipping 30 matching lines...) Expand all Loading... |
321 private: | 335 private: |
322 enum { | 336 enum { |
323 kQuadCount = 8, // should handle most conics | 337 kQuadCount = 8, // should handle most conics |
324 kPointCount = 1 + 2 * kQuadCount, | 338 kPointCount = 1 + 2 * kQuadCount, |
325 }; | 339 }; |
326 SkAutoSTMalloc<kPointCount, SkPoint> fStorage; | 340 SkAutoSTMalloc<kPointCount, SkPoint> fStorage; |
327 int fQuadCount; // #quads for current usage | 341 int fQuadCount; // #quads for current usage |
328 }; | 342 }; |
329 | 343 |
330 #endif | 344 #endif |
OLD | NEW |