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

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

Issue 216503004: SK_SUPPORT_LEGACY_GRTYPES to hide duplicate types from SkTypes.h (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 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 13 matching lines...) Expand all
24 const SkRect& pathBounds); 24 const SkRect& pathBounds);
25 25
26 /// Since we divide by tol if we're computing exact worst-case bounds, 26 /// Since we divide by tol if we're computing exact worst-case bounds,
27 /// very small tolerances will be increased to gMinCurveTol. 27 /// very small tolerances will be increased to gMinCurveTol.
28 int worstCasePointCount(const SkPath&, 28 int worstCasePointCount(const SkPath&,
29 int* subpaths, 29 int* subpaths,
30 SkScalar tol); 30 SkScalar tol);
31 31
32 /// Since we divide by tol if we're computing exact worst-case bounds, 32 /// Since we divide by tol if we're computing exact worst-case bounds,
33 /// very small tolerances will be increased to gMinCurveTol. 33 /// very small tolerances will be increased to gMinCurveTol.
34 uint32_t quadraticPointCount(const GrPoint points[], SkScalar tol); 34 uint32_t quadraticPointCount(const SkPoint points[], SkScalar tol);
35 35
36 uint32_t generateQuadraticPoints(const GrPoint& p0, 36 uint32_t generateQuadraticPoints(const SkPoint& p0,
37 const GrPoint& p1, 37 const SkPoint& p1,
38 const GrPoint& p2, 38 const SkPoint& p2,
39 SkScalar tolSqd, 39 SkScalar tolSqd,
40 GrPoint** points, 40 SkPoint** points,
41 uint32_t pointsLeft); 41 uint32_t pointsLeft);
42 42
43 /// Since we divide by tol if we're computing exact worst-case bounds, 43 /// Since we divide by tol if we're computing exact worst-case bounds,
44 /// very small tolerances will be increased to gMinCurveTol. 44 /// very small tolerances will be increased to gMinCurveTol.
45 uint32_t cubicPointCount(const GrPoint points[], SkScalar tol); 45 uint32_t cubicPointCount(const SkPoint points[], SkScalar tol);
46 46
47 uint32_t generateCubicPoints(const GrPoint& p0, 47 uint32_t generateCubicPoints(const SkPoint& p0,
48 const GrPoint& p1, 48 const SkPoint& p1,
49 const GrPoint& p2, 49 const SkPoint& p2,
50 const GrPoint& p3, 50 const SkPoint& p3,
51 SkScalar tolSqd, 51 SkScalar tolSqd,
52 GrPoint** points, 52 SkPoint** points,
53 uint32_t pointsLeft); 53 uint32_t pointsLeft);
54 54
55 // A 2x3 matrix that goes from the 2d space coordinates to UV space where 55 // A 2x3 matrix that goes from the 2d space coordinates to UV space where
56 // u^2-v = 0 specifies the quad. The matrix is determined by the control 56 // u^2-v = 0 specifies the quad. The matrix is determined by the control
57 // points of the quadratic. 57 // points of the quadratic.
58 class QuadUVMatrix { 58 class QuadUVMatrix {
59 public: 59 public:
60 QuadUVMatrix() {}; 60 QuadUVMatrix() {};
61 // Initialize the matrix from the control pts 61 // Initialize the matrix from the control pts
62 QuadUVMatrix(const GrPoint controlPts[3]) { this->set(controlPts); } 62 QuadUVMatrix(const SkPoint controlPts[3]) { this->set(controlPts); }
63 void set(const GrPoint controlPts[3]); 63 void set(const SkPoint controlPts[3]);
64 64
65 /** 65 /**
66 * Applies the matrix to vertex positions to compute UV coords. This 66 * Applies the matrix to vertex positions to compute UV coords. This
67 * has been templated so that the compiler can easliy unroll the loop 67 * has been templated so that the compiler can easliy unroll the loop
68 * and reorder to avoid stalling for loads. The assumption is that a 68 * and reorder to avoid stalling for loads. The assumption is that a
69 * path renderer will have a small fixed number of vertices that it 69 * path renderer will have a small fixed number of vertices that it
70 * uploads for each quad. 70 * uploads for each quad.
71 * 71 *
72 * N is the number of vertices. 72 * N is the number of vertices.
73 * STRIDE is the size of each vertex. 73 * STRIDE is the size of each vertex.
74 * UV_OFFSET is the offset of the UV values within each vertex. 74 * UV_OFFSET is the offset of the UV values within each vertex.
75 * vertices is a pointer to the first vertex. 75 * vertices is a pointer to the first vertex.
76 */ 76 */
77 template <int N, size_t STRIDE, size_t UV_OFFSET> 77 template <int N, size_t STRIDE, size_t UV_OFFSET>
78 void apply(const void* vertices) { 78 void apply(const void* vertices) {
79 intptr_t xyPtr = reinterpret_cast<intptr_t>(vertices); 79 intptr_t xyPtr = reinterpret_cast<intptr_t>(vertices);
80 intptr_t uvPtr = reinterpret_cast<intptr_t>(vertices) + UV_OFFSET; 80 intptr_t uvPtr = reinterpret_cast<intptr_t>(vertices) + UV_OFFSET;
81 float sx = fM[0]; 81 float sx = fM[0];
82 float kx = fM[1]; 82 float kx = fM[1];
83 float tx = fM[2]; 83 float tx = fM[2];
84 float ky = fM[3]; 84 float ky = fM[3];
85 float sy = fM[4]; 85 float sy = fM[4];
86 float ty = fM[5]; 86 float ty = fM[5];
87 for (int i = 0; i < N; ++i) { 87 for (int i = 0; i < N; ++i) {
88 const GrPoint* xy = reinterpret_cast<const GrPoint*>(xyPtr); 88 const SkPoint* xy = reinterpret_cast<const SkPoint*>(xyPtr);
89 GrPoint* uv = reinterpret_cast<GrPoint*>(uvPtr); 89 SkPoint* uv = reinterpret_cast<SkPoint*>(uvPtr);
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
(...skipping 12 matching lines...) Expand all
112 // result is sets of 3 points in quads (TODO: share endpoints in returned 112 // result is sets of 3 points in quads (TODO: share endpoints in returned
113 // array) 113 // array)
114 // When we approximate a cubic {a,b,c,d} with a quadratic we may have to 114 // When we approximate a cubic {a,b,c,d} with a quadratic we may have to
115 // ensure that the new control point lies between the lines ab and cd. The 115 // ensure that the new control point lies between the lines ab and cd. The
116 // convex path renderer requires this. It starts with a path where all the 116 // convex path renderer requires this. It starts with a path where all the
117 // control points taken together form a convex polygon. It relies on this 117 // control points taken together form a convex polygon. It relies on this
118 // property and the quadratic approximation of cubics step cannot alter it. 118 // property and the quadratic approximation of cubics step cannot alter it.
119 // Setting constrainWithinTangents to true enforces this property. When this 119 // Setting constrainWithinTangents to true enforces this property. When this
120 // is true the cubic must be simple and dir must specify the orientation of 120 // is true the cubic must be simple and dir must specify the orientation of
121 // the cubic. Otherwise, dir is ignored. 121 // the cubic. Otherwise, dir is ignored.
122 void convertCubicToQuads(const GrPoint p[4], 122 void convertCubicToQuads(const SkPoint p[4],
123 SkScalar tolScale, 123 SkScalar tolScale,
124 bool constrainWithinTangents, 124 bool constrainWithinTangents,
125 SkPath::Direction dir, 125 SkPath::Direction dir,
126 SkTArray<SkPoint, true>* quads); 126 SkTArray<SkPoint, true>* quads);
127 127
128 // 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)
129 // 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
130 // 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.
131 // Return value: 131 // Return value:
132 // 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,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // K = (klm[0], klm[1], klm[2]) 164 // K = (klm[0], klm[1], klm[2])
165 // L = (klm[3], klm[4], klm[5]) 165 // L = (klm[3], klm[4], klm[5])
166 // M = (klm[6], klm[7], klm[8]) 166 // M = (klm[6], klm[7], klm[8])
167 // 167 //
168 // Notice that the klm lines are calculated in the same space as the input c ontrol points. 168 // Notice that the klm lines are calculated in the same space as the input c ontrol points.
169 // If you transform the points the lines will also need to be transformed. T his can be done 169 // If you transform the points the lines will also need to be transformed. T his can be done
170 // by mapping the lines with the inverse-transpose of the matrix used to map the points. 170 // by mapping the lines with the inverse-transpose of the matrix used to map the points.
171 void getCubicKLM(const SkPoint p[4], SkScalar klm[9]); 171 void getCubicKLM(const SkPoint p[4], SkScalar klm[9]);
172 }; 172 };
173 #endif 173 #endif
OLDNEW
« include/gpu/GrPoint.h ('K') | « src/gpu/GrOvalRenderer.cpp ('k') | src/gpu/GrPathUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698