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

Side by Side Diff: src/gpu/GrPathUtils.h

Issue 22900007: Add direct bezier cubic support for GPU shaders (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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
OLDNEW
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 uv->fX = sx * xy->fX + kx * xy->fY + tx; 90 uv->fX = sx * xy->fX + kx * xy->fY + tx;
91 uv->fY = ky * xy->fX + sy * xy->fY + ty; 91 uv->fY = ky * xy->fX + sy * xy->fY + ty;
92 xyPtr += STRIDE; 92 xyPtr += STRIDE;
93 uvPtr += STRIDE; 93 uvPtr += STRIDE;
94 } 94 }
95 } 95 }
96 private: 96 private:
97 float fM[6]; 97 float fM[6];
98 }; 98 };
99 99
100 ///////////////////////////////////////////////////////////////////////////////
101 // Cubics
100 102
101 // Converts a cubic into a sequence of quads. If working in device space 103 // Converts a cubic into a sequence of quads. If working in device space
102 // use tolScale = 1, otherwise set based on stretchiness of the matrix. The 104 // use tolScale = 1, otherwise set based on stretchiness of the matrix. The
103 // result is sets of 3 points in quads (TODO: share endpoints in returned 105 // result is sets of 3 points in quads (TODO: share endpoints in returned
104 // array) 106 // array)
105 // When we approximate a cubic {a,b,c,d} with a quadratic we may have to 107 // When we approximate a cubic {a,b,c,d} with a quadratic we may have to
106 // ensure that the new control point lies between the lines ab and cd. The 108 // ensure that the new control point lies between the lines ab and cd. The
107 // convex path renderer requires this. It starts with a path where all the 109 // convex path renderer requires this. It starts with a path where all the
108 // control points taken together form a convex polygon. It relies on this 110 // control points taken together form a convex polygon. It relies on this
109 // property and the quadratic approximation of cubics step cannot alter it. 111 // property and the quadratic approximation of cubics step cannot alter it.
110 // Setting constrainWithinTangents to true enforces this property. When this 112 // Setting constrainWithinTangents to true enforces this property. When this
111 // is true the cubic must be simple and dir must specify the orientation of 113 // is true the cubic must be simple and dir must specify the orientation of
112 // the cubic. Otherwise, dir is ignored. 114 // the cubic. Otherwise, dir is ignored.
113 void convertCubicToQuads(const GrPoint p[4], 115 void convertCubicToQuads(const GrPoint p[4],
114 SkScalar tolScale, 116 SkScalar tolScale,
115 bool constrainWithinTangents, 117 bool constrainWithinTangents,
116 SkPath::Direction dir, 118 SkPath::Direction dir,
117 SkTArray<SkPoint, true>* quads); 119 SkTArray<SkPoint, true>* quads);
120
121 // Chops the cubic bezier passed in by src, at the double point (intersectio n point)
122 // if the curve is a cubic loop. If it is a loop, there will be two parametr ic values for
123 // the double point: ls and ms. We chop the cubic at these values if they ar e between 0 and 1.
124 // Return value:
125 // Value of 3: ls and ms are both between (0,1), and dst will contain the th ree cubics,
126 // dst[0..3], dst[3..6], and dst[6..9] if dst is not NULL
127 // Value of 2: Only one of ls and ms are between (0,1), and dst will contain the two cubics,
128 // dst[0..3] and dst[3..6] if dst is not NULL
129 // Value of 1: Neither ls or ms are between (0,1), and dst will contain the one original cubic,
130 // dst[0..3] if dst is not NULL
131 //
132 // Optional KLM Calculation:
133 // The function can also return the KLM linear functionals for the chopped c ubic implicit form
134 // of K^3 - LM.
135 // It will calculate a single set of KLM values that can be shared by all su b cubics, except
136 // for the subsection that is "the loop" the K and L values need to be negat ed.
137 // Input:
138 // Need to send in the device coords for the original src points. The KLM ca lculations will be
139 // done using the points in device space.
140 // Output:
141 // klm: Holds the values for the linear functionals as:
142 // K = (klm[0], klm[1], klm[2])
143 // L = (klm[3], klm[4], klm[5])
144 // M = (klm[6], klm[7], klm[8])
145 // klm_rev: These values are flags for the corresponding sub cubic saying wh ether or not
146 // the K and L values need to be flipped. A value of -1.f means fli p K and L and
147 // a value of 1.f means do nothing
148 int chopCubicAtLoopIntersection(const SkPoint src[4], SkPoint dst[10] = NULL ,
149 SkScalar klm[9] = NULL, SkScalar klm_rev[3] = NULL,
150 const SkPoint devPts[4] = NULL);
151
152 // Input is p which holds the 4 control points of a non-rational cubic Bezie r curve.
153 // Output is the coefficients of the three linear functionals K, L, & M whic h
154 // represent the implicit form of the cubic as f(x,y,w) = K^3 - LM. The w te rm
155 // will always be 1. The output is stored in the array klm, where the values are:
156 // K = (klm[0], klm[1], klm[2])
157 // L = (klm[3], klm[4], klm[5])
158 // M = (klm[6], klm[7], klm[8])
159 void getCubicKLM(const SkPoint p[4], SkScalar klm[9]);
118 }; 160 };
119 #endif 161 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698