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

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

Issue 429343004: Stopped skipping tests in dm of SkPatch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Added number of points and colors constants 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
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 }; 70 };
71 71
72 // Enum for corner colors also clockwise. 72 // Enum for corner colors also clockwise.
73 enum CornerColors { 73 enum CornerColors {
74 kTopLeft_CornerColors = 0, 74 kTopLeft_CornerColors = 0,
75 kTopRight_CornerColors, 75 kTopRight_CornerColors,
76 kBottomRight_CornerColors, 76 kBottomRight_CornerColors,
77 kBottomLeft_CornerColors 77 kBottomLeft_CornerColors
78 }; 78 };
79 79
80 static const int kNumCtrlPts = 12, kNumColors = 4;
81
80 /** 82 /**
81 * Points are in the following order: 83 * Points are in the following order:
82 * (top curve) 84 * (top curve)
83 * 0 1 2 3 85 * 0 1 2 3
84 * (left curve) 11 4 (right curve) 86 * (left curve) 11 4 (right curve)
85 * 10 5 87 * 10 5
86 * 9 8 7 6 88 * 9 8 7 6
87 * (bottom curve) 89 * (bottom curve)
88 */ 90 */
89 SkPatch(SkPoint points[12], SkColor colors[4]); 91 SkPatch() { }
92 SkPatch(const SkPoint points[12], const SkColor colors[4]);
90 93
91 /** 94 /**
92 * Function that evaluates the coons patch interpolation. 95 * Function that evaluates the coons patch interpolation.
93 * data refers to the pointer of the PatchData struct in which the tessellat ion data is set. 96 * data refers to the pointer of the PatchData struct in which the tessellat ion data is set.
94 * lod refers the level of detail for each axis. 97 * lod refers the level of detail for each axis.
95 */ 98 */
96 bool getVertexData(SkPatch::VertexData* data, int lodX, int lodY) const; 99 bool getVertexData(SkPatch::VertexData* data, int lodX, int lodY) const;
97 100
98 void getTopPoints(SkPoint points[4]) const { 101 void getTopPoints(SkPoint points[4]) const {
99 points[0] = fCtrlPoints[kTopP0_CubicCtrlPts]; 102 points[0] = fCtrlPoints[kTopP0_CubicCtrlPts];
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 134 }
132 135
133 const SkPoint* getControlPoints() const { 136 const SkPoint* getControlPoints() const {
134 return fCtrlPoints; 137 return fCtrlPoints;
135 } 138 }
136 139
137 const SkColor* getColors() const { 140 const SkColor* getColors() const {
138 return fCornerColors; 141 return fCornerColors;
139 } 142 }
140 143
144 void setPoints(const SkPoint points[12]) {
145 memcpy(fCtrlPoints, points, kNumCtrlPts * sizeof(SkPoint));
146
147 }
148
149 void setColors(const SkColor colors[4]) {
150 memcpy(fCornerColors, colors, kNumColors * sizeof(SkColor));
151 }
152
153 void reset(const SkPoint points[12], const SkColor colors[4]) {
154 this->setPoints(points);
155 this->setColors(colors);
156 }
157
158 /**
159 * Write the patch to the buffer, and return the number of bytes written.
160 * If buffer is NULL, it still returns the number of bytes.
161 */
162 size_t writeToMemory(void* buffer) const;
163
164 /**
165 * Initializes the patch from the buffer
166 *
167 * buffer Memory to read from
168 * length Amount of memory available in the buffer
169 * number of bytes read (must be a multiple of 4) or
170 * 0 if there was not enough memory available
171 */
172 size_t readFromMemory(const void* buffer, size_t length);
173
141 private: 174 private:
142 SkPoint fCtrlPoints[12]; 175 SkPoint fCtrlPoints[12];
143 SkColor fCornerColors[4]; 176 SkColor fCornerColors[4];
144 }; 177 };
145 178
146 #endif 179 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698