| OLD | NEW |
| 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 #ifndef GrPathUtils_DEFINED | 8 #ifndef GrPathUtils_DEFINED |
| 9 #define GrPathUtils_DEFINED | 9 #define GrPathUtils_DEFINED |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // conic, K^2 - LM. | 101 // conic, K^2 - LM. |
| 102 // | 102 // |
| 103 // Output: | 103 // Output: |
| 104 // K = (klm[0], klm[1], klm[2]) | 104 // K = (klm[0], klm[1], klm[2]) |
| 105 // L = (klm[3], klm[4], klm[5]) | 105 // L = (klm[3], klm[4], klm[5]) |
| 106 // M = (klm[6], klm[7], klm[8]) | 106 // M = (klm[6], klm[7], klm[8]) |
| 107 void getConicKLM(const SkPoint p[3], const SkScalar weight, SkScalar klm[9])
; | 107 void getConicKLM(const SkPoint p[3], const SkScalar weight, SkScalar klm[9])
; |
| 108 | 108 |
| 109 // Converts a cubic into a sequence of quads. If working in device space | 109 // Converts a cubic into a sequence of quads. If working in device space |
| 110 // use tolScale = 1, otherwise set based on stretchiness of the matrix. The | 110 // use tolScale = 1, otherwise set based on stretchiness of the matrix. The |
| 111 // result is sets of 3 points in quads (TODO: share endpoints in returned | 111 // result is sets of 3 points in quads. |
| 112 // array) | 112 void convertCubicToQuads(const SkPoint p[4], |
| 113 SkScalar tolScale, |
| 114 SkTArray<SkPoint, true>* quads); |
| 115 |
| 113 // When we approximate a cubic {a,b,c,d} with a quadratic we may have to | 116 // When we approximate a cubic {a,b,c,d} with a quadratic we may have to |
| 114 // ensure that the new control point lies between the lines ab and cd. The | 117 // ensure that the new control point lies between the lines ab and cd. The |
| 115 // convex path renderer requires this. It starts with a path where all the | 118 // convex path renderer requires this. It starts with a path where all the |
| 116 // control points taken together form a convex polygon. It relies on this | 119 // control points taken together form a convex polygon. It relies on this |
| 117 // property and the quadratic approximation of cubics step cannot alter it. | 120 // property and the quadratic approximation of cubics step cannot alter it. |
| 118 // Setting constrainWithinTangents to true enforces this property. When this | 121 // This variation enforces this constraint. The cubic must be simple and dir |
| 119 // is true the cubic must be simple and dir must specify the orientation of | 122 // must specify the orientation of the contour containing the cubic. |
| 120 // the cubic. Otherwise, dir is ignored. | 123 void convertCubicToQuadsConstrainToTangents(const SkPoint p[4], |
| 121 void convertCubicToQuads(const SkPoint p[4], | 124 SkScalar tolScale, |
| 122 SkScalar tolScale, | 125 SkPathPriv::FirstDirection dir, |
| 123 bool constrainWithinTangents, | 126 SkTArray<SkPoint, true>* quads); |
| 124 SkPathPriv::FirstDirection dir, | |
| 125 SkTArray<SkPoint, true>* quads); | |
| 126 | 127 |
| 127 // Chops the cubic bezier passed in by src, at the double point (intersectio
n point) | 128 // Chops the cubic bezier passed in by src, at the double point (intersectio
n point) |
| 128 // if the curve is a cubic loop. If it is a loop, there will be two parametr
ic values for | 129 // if the curve is a cubic loop. If it is a loop, there will be two parametr
ic values for |
| 129 // the double point: ls and ms. We chop the cubic at these values if they ar
e between 0 and 1. | 130 // the double point: ls and ms. We chop the cubic at these values if they ar
e between 0 and 1. |
| 130 // Return value: | 131 // Return value: |
| 131 // Value of 3: ls and ms are both between (0,1), and dst will contain the th
ree cubics, | 132 // Value of 3: ls and ms are both between (0,1), and dst will contain the th
ree cubics, |
| 132 // dst[0..3], dst[3..6], and dst[6..9] if dst is not nullptr | 133 // dst[0..3], dst[3..6], and dst[6..9] if dst is not nullptr |
| 133 // Value of 2: Only one of ls and ms are between (0,1), and dst will contain
the two cubics, | 134 // Value of 2: Only one of ls and ms are between (0,1), and dst will contain
the two cubics, |
| 134 // dst[0..3] and dst[3..6] if dst is not nullptr | 135 // dst[0..3] and dst[3..6] if dst is not nullptr |
| 135 // Value of 1: Neither ls or ms are between (0,1), and dst will contain the
one original cubic, | 136 // Value of 1: Neither ls or ms are between (0,1), and dst will contain the
one original cubic, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 void getCubicKLM(const SkPoint p[4], SkScalar klm[9]); | 171 void getCubicKLM(const SkPoint p[4], SkScalar klm[9]); |
| 171 | 172 |
| 172 // When tessellating curved paths into linear segments, this defines the max
imum distance | 173 // When tessellating curved paths into linear segments, this defines the max
imum distance |
| 173 // in screen space which a segment may deviate from the mathmatically correc
t value. | 174 // in screen space which a segment may deviate from the mathmatically correc
t value. |
| 174 // Above this value, the segment will be subdivided. | 175 // Above this value, the segment will be subdivided. |
| 175 // This value was chosen to approximate the supersampling accuracy of the ra
ster path (16 | 176 // This value was chosen to approximate the supersampling accuracy of the ra
ster path (16 |
| 176 // samples, or one quarter pixel). | 177 // samples, or one quarter pixel). |
| 177 static const SkScalar kDefaultTolerance = SkDoubleToScalar(0.25); | 178 static const SkScalar kDefaultTolerance = SkDoubleToScalar(0.25); |
| 178 }; | 179 }; |
| 179 #endif | 180 #endif |
| OLD | NEW |