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

Side by Side Diff: include/core/SkPatch.h

Issue 424663006: SkCanvas interface for drawing a patch. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixed implicit casting in patch.cpp Created 6 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
« no previous file with comments | « include/core/SkDevice.h ('k') | include/utils/SkDeferredCanvas.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 SkPatch_DEFINED 8 #ifndef SkPatch_DEFINED
9 #define SkPatch_DEFINED 9 #define SkPatch_DEFINED
10 10
(...skipping 28 matching lines...) Expand all
39 , fIndices(NULL) { } 39 , fIndices(NULL) { }
40 40
41 ~VertexData() { 41 ~VertexData() {
42 SkDELETE_ARRAY(fPoints); 42 SkDELETE_ARRAY(fPoints);
43 SkDELETE_ARRAY(fTexCoords); 43 SkDELETE_ARRAY(fTexCoords);
44 SkDELETE_ARRAY(fColors); 44 SkDELETE_ARRAY(fColors);
45 SkDELETE_ARRAY(fIndices); 45 SkDELETE_ARRAY(fIndices);
46 } 46 }
47 }; 47 };
48 48
49 // Enums for control points based on the order specified in the constructor (clockwise).
49 enum CubicCtrlPts { 50 enum CubicCtrlPts {
50 kTopP0_CubicCtrlPts = 0, 51 kTopP0_CubicCtrlPts = 0,
51 kTopP1_CubicCtrlPts = 1, 52 kTopP1_CubicCtrlPts = 1,
52 kTopP2_CubicCtrlPts = 2, 53 kTopP2_CubicCtrlPts = 2,
53 kTopP3_CubicCtrlPts = 3, 54 kTopP3_CubicCtrlPts = 3,
54 55
55 kRightP0_CubicCtrlPts = 3, 56 kRightP0_CubicCtrlPts = 3,
56 kRightP1_CubicCtrlPts = 4, 57 kRightP1_CubicCtrlPts = 4,
57 kRightP2_CubicCtrlPts = 5, 58 kRightP2_CubicCtrlPts = 5,
58 kRightP3_CubicCtrlPts = 6, 59 kRightP3_CubicCtrlPts = 6,
59 60
60 kBottomP0_CubicCtrlPts = 9, 61 kBottomP0_CubicCtrlPts = 9,
61 kBottomP1_CubicCtrlPts = 8, 62 kBottomP1_CubicCtrlPts = 8,
62 kBottomP2_CubicCtrlPts = 7, 63 kBottomP2_CubicCtrlPts = 7,
63 kBottomP3_CubicCtrlPts = 6, 64 kBottomP3_CubicCtrlPts = 6,
64 65
65 kLeftP0_CubicCtrlPts = 0, 66 kLeftP0_CubicCtrlPts = 0,
66 kLeftP1_CubicCtrlPts = 11, 67 kLeftP1_CubicCtrlPts = 11,
67 kLeftP2_CubicCtrlPts = 10, 68 kLeftP2_CubicCtrlPts = 10,
68 kLeftP3_CubicCtrlPts = 9, 69 kLeftP3_CubicCtrlPts = 9,
69 }; 70 };
70 71
72 // Enum for corner colors also clockwise.
73 enum CornerColors {
74 kTopLeft_CornerColors = 0,
75 kTopRight_CornerColors,
76 kBottomRight_CornerColors,
77 kBottomLeft_CornerColors
78 };
79
71 /** 80 /**
72 * Points are in the following order: 81 * Points are in the following order:
73 * (top curve) 82 * (top curve)
74 * 0 1 2 3 83 * 0 1 2 3
75 * (left curve) 11 4 (right curve) 84 * (left curve) 11 4 (right curve)
76 * 10 5 85 * 10 5
77 * 9 8 7 6 86 * 9 8 7 6
78 * (bottom curve) 87 * (bottom curve)
79 * Used pointer to an array to guarantee that this method receives an array of 4 SkColors
80 */ 88 */
81 SkPatch(SkPoint points[12], SkColor colors[4]); 89 SkPatch(SkPoint points[12], SkColor colors[4]);
82 90
83 /** 91 /**
84 * Function that evaluates the coons patch interpolation. 92 * Function that evaluates the coons patch interpolation.
85 * data refers to the pointer of the PatchData struct in which the tessellat ion data is set. 93 * data refers to the pointer of the PatchData struct in which the tessellat ion data is set.
86 * divisions defines the number of steps in which the SkPatch is going to be subdivided per 94 * lod refers the level of detail for each axis.
87 * axis.
88 */ 95 */
89 bool getVertexData(SkPatch::VertexData* data, int divisions); 96 bool getVertexData(SkPatch::VertexData* data, int lodX, int lodY) const;
90 97
91 void getTopPoints(SkPoint points[4]) { 98 void getTopPoints(SkPoint points[4]) const {
92 points[0] = fCtrlPoints[kTopP0_CubicCtrlPts]; 99 points[0] = fCtrlPoints[kTopP0_CubicCtrlPts];
93 points[1] = fCtrlPoints[kTopP1_CubicCtrlPts]; 100 points[1] = fCtrlPoints[kTopP1_CubicCtrlPts];
94 points[2] = fCtrlPoints[kTopP2_CubicCtrlPts]; 101 points[2] = fCtrlPoints[kTopP2_CubicCtrlPts];
95 points[3] = fCtrlPoints[kTopP3_CubicCtrlPts]; 102 points[3] = fCtrlPoints[kTopP3_CubicCtrlPts];
96 } 103 }
97 104
98 void getBottomPoints(SkPoint points[4]) { 105 void getBottomPoints(SkPoint points[4]) const {
99 points[0] = fCtrlPoints[kBottomP0_CubicCtrlPts]; 106 points[0] = fCtrlPoints[kBottomP0_CubicCtrlPts];
100 points[1] = fCtrlPoints[kBottomP1_CubicCtrlPts]; 107 points[1] = fCtrlPoints[kBottomP1_CubicCtrlPts];
101 points[2] = fCtrlPoints[kBottomP2_CubicCtrlPts]; 108 points[2] = fCtrlPoints[kBottomP2_CubicCtrlPts];
102 points[3] = fCtrlPoints[kBottomP3_CubicCtrlPts]; 109 points[3] = fCtrlPoints[kBottomP3_CubicCtrlPts];
103 } 110 }
104 111
105 void getLeftPoints(SkPoint points[4]) { 112 void getLeftPoints(SkPoint points[4]) const {
106 points[0] = fCtrlPoints[kLeftP0_CubicCtrlPts]; 113 points[0] = fCtrlPoints[kLeftP0_CubicCtrlPts];
107 points[1] = fCtrlPoints[kLeftP1_CubicCtrlPts]; 114 points[1] = fCtrlPoints[kLeftP1_CubicCtrlPts];
108 points[2] = fCtrlPoints[kLeftP2_CubicCtrlPts]; 115 points[2] = fCtrlPoints[kLeftP2_CubicCtrlPts];
109 points[3] = fCtrlPoints[kLeftP3_CubicCtrlPts]; 116 points[3] = fCtrlPoints[kLeftP3_CubicCtrlPts];
110 } 117 }
111 118
112 void getRightPoints(SkPoint points[4]) { 119 void getRightPoints(SkPoint points[4]) const {
113 points[0] = fCtrlPoints[kRightP0_CubicCtrlPts]; 120 points[0] = fCtrlPoints[kRightP0_CubicCtrlPts];
114 points[1] = fCtrlPoints[kRightP1_CubicCtrlPts]; 121 points[1] = fCtrlPoints[kRightP1_CubicCtrlPts];
115 points[2] = fCtrlPoints[kRightP2_CubicCtrlPts]; 122 points[2] = fCtrlPoints[kRightP2_CubicCtrlPts];
116 points[3] = fCtrlPoints[kRightP3_CubicCtrlPts]; 123 points[3] = fCtrlPoints[kRightP3_CubicCtrlPts];
117 } 124 }
118 125
126 void getCornerPoints(SkPoint points[4]) const {
127 points[0] = fCtrlPoints[kTopP0_CubicCtrlPts];
128 points[1] = fCtrlPoints[kTopP3_CubicCtrlPts];
129 points[2] = fCtrlPoints[kBottomP3_CubicCtrlPts];
130 points[3] = fCtrlPoints[kBottomP0_CubicCtrlPts];
131 }
132
133 const SkPoint* getControlPoints() const {
134 return fCtrlPoints;
135 }
136
137 const SkColor* getColors() const {
138 return fCornerColors;
139 }
140
119 private: 141 private:
120 SkPoint fCtrlPoints[12]; 142 SkPoint fCtrlPoints[12];
121 SkPMColor fCornerColors[4]; 143 SkColor fCornerColors[4];
122 }; 144 };
123 145
124 #endif 146 #endif
OLDNEW
« no previous file with comments | « include/core/SkDevice.h ('k') | include/utils/SkDeferredCanvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698