OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2014 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #ifndef SkPatch_DEFINED | |
9 #define SkPatch_DEFINED | |
10 | |
11 #include "SkColor.h" | |
12 #include "SkPoint.h" | |
13 | |
14 /** | |
15 * Class that represents a coons patch. | |
16 */ | |
17 class SK_API SkPatch { | |
18 | |
19 public: | |
20 | |
21 struct PatchData { | |
bsalomon
2014/07/25 13:14:34
Maybe a comment here about how this is to be used.
dandov
2014/07/25 14:08:14
Done.
| |
22 int fVertCount, fIndexCount; | |
23 SkPoint* fPoints; | |
24 SkPoint* fTexCoords; | |
25 uint32_t* fColors; | |
26 uint16_t* fIndices; | |
27 | |
28 PatchData() | |
29 : fVertCount(0) | |
30 , fIndexCount(0) | |
31 , fPoints(NULL) | |
32 , fTexCoords(NULL) | |
33 , fColors(NULL) | |
34 , fIndices(NULL) { } | |
35 | |
36 ~PatchData() { | |
37 SkDELETE_ARRAY(fPoints); | |
38 SkDELETE_ARRAY(fTexCoords); | |
39 SkDELETE_ARRAY(fColors); | |
40 SkDELETE_ARRAY(fIndices); | |
41 } | |
42 }; | |
43 | |
44 /** | |
45 * Points are in the following order: | |
46 * (bottom curve) | |
bsalomon
2014/07/25 13:14:34
I thought from our discussion yesterday that the t
dandov
2014/07/25 14:08:14
Sorry I uploaded this cl before our discussion. It
| |
47 * 0 1 2 3 | |
48 * (left curve) 11 4 (right curve) | |
49 * 10 5 | |
50 * 9 8 7 6 | |
51 * (top curve) | |
52 * Used pointer to an array to guarantee that this method receives an array of 4 SkColors | |
53 */ | |
54 SkPatch(SkPoint points[12], SkColor colors[4], int res); | |
55 | |
56 void getVertexData(SkPatch::PatchData* data); | |
57 | |
58 void getBottomPoints(SkPoint points[4]) { | |
59 points[0] = fCtrlPoints[0]; | |
60 points[1] = fCtrlPoints[1]; | |
61 points[2] = fCtrlPoints[2]; | |
62 points[3] = fCtrlPoints[3]; | |
63 } | |
64 | |
65 const void getTopPoints(SkPoint points[4]) { | |
bsalomon
2014/07/25 13:14:34
const void? But I wanna change the void!
dandov
2014/07/25 14:08:14
Missed those ones, thanks.
| |
66 points[0] = fCtrlPoints[9]; | |
67 points[1] = fCtrlPoints[8]; | |
68 points[2] = fCtrlPoints[7]; | |
69 points[3] = fCtrlPoints[6]; | |
70 } | |
71 | |
72 const void getLeftPoints(SkPoint points[4]) { | |
73 points[0] = fCtrlPoints[0]; | |
74 points[1] = fCtrlPoints[11]; | |
75 points[2] = fCtrlPoints[10]; | |
76 points[3] = fCtrlPoints[9]; | |
77 } | |
78 | |
79 const void getRightPoints(SkPoint points[4]) { | |
80 points[0] = fCtrlPoints[3]; | |
81 points[1] = fCtrlPoints[4]; | |
82 points[2] = fCtrlPoints[5]; | |
83 points[3] = fCtrlPoints[6]; | |
84 } | |
85 | |
86 | |
87 private: | |
88 SkPoint fCtrlPoints[12]; | |
89 SkPMColor fCornerColors[4]; | |
90 int fDivX, fDivY; | |
91 }; | |
92 | |
93 #endif | |
OLD | NEW |