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 class SkFwDCubicEvaluator { | |
15 | |
16 public: | |
17 SkFwDCubicEvaluator(){ } | |
18 | |
19 /** | |
20 * Receives the 4 control points for the cubic. | |
21 */ | |
22 SkFwDCubicEvaluator(SkPoint a, SkPoint b, SkPoint c, SkPoint d); | |
23 | |
24 /** | |
25 * Resets the forward differences evaluator to the first value of t = 0. | |
26 */ | |
27 void reset(int res); | |
egdaniel
2014/07/22 19:09:36
what exactly is the meaning behind res? Maybe I ju
dandov
2014/07/22 20:23:28
I changed the name to divisions meaning the number
| |
28 | |
29 /* | |
30 * Evaluate cubic bezier using forward differences. | |
31 * Call operator* to check if the next value is still within the range t=[0, 1]. | |
32 * Call operator++ to obtain the SkPoint sampled at the next t. | |
33 * Call reset to start sampling from t=0 | |
34 */ | |
35 inline bool operator*() { | |
egdaniel
2014/07/22 19:09:35
The * operator seems weird to be used as a bool (u
dandov
2014/07/22 20:23:28
I adjusted the operator* to get the current value
| |
36 return fCurrent <= fMax; | |
37 } | |
38 | |
39 inline SkPoint operator++() { | |
40 SkPoint point = fFwDiff[0]; | |
41 fFwDiff[0] += fFwDiff[1]; | |
42 fFwDiff[1] += fFwDiff[2]; | |
43 fFwDiff[2] += fFwDiff[3]; | |
44 fCurrent++; | |
45 return point; | |
46 } | |
47 | |
48 inline SkPoint operator++(int) { | |
49 //repeat this code? inline is affected if not? | |
50 SkPoint point = fFwDiff[0]; | |
51 fFwDiff[0] += fFwDiff[1]; | |
52 fFwDiff[1] += fFwDiff[2]; | |
53 fFwDiff[2] += fFwDiff[3]; | |
54 fCurrent++; | |
55 return point; | |
56 } | |
57 | |
58 const SkPoint* getPoints(); | |
59 | |
60 const SkPoint* getCoefs(); | |
egdaniel
2014/07/22 19:09:35
Do you have a need for getCoefs() or getResolution
dandov
2014/07/22 20:23:28
Done.
| |
61 | |
62 int getResolution(); | |
63 | |
64 private: | |
65 int fMax, fCurrent, fRes; | |
66 SkPoint fFwDiff[4], fCoefs[4], fPoints[4]; | |
67 }; | |
68 | |
69 /** | |
70 * Class that represents a coons patch. | |
71 */ | |
72 class SK_API SkPatch { | |
73 | |
74 public: | |
75 /* | |
76 * Points are in the following order: | |
77 * (bottom curve) | |
78 * 0 1 2 3 | |
79 * (left curve) 8 10 (right curve) | |
80 * 9 11 | |
81 * 4 5 6 7 | |
82 * (top curve) | |
83 * Used pointer to an array to guarantee that this method receives an array of 4 SkColors | |
84 */ | |
85 SkPatch(SkPoint points[12], SkColor (*colors)[4], int res); | |
86 | |
87 ~SkPatch(); | |
88 | |
89 void clean(); | |
90 | |
91 const SkPoint* getTopPoints() { return fTop.getPoints(); } | |
92 | |
93 const SkPoint* getLeftPoints() { return fLeft.getPoints(); } | |
94 | |
95 const SkPoint* getRightPoints() { return fRight.getPoints(); } | |
96 | |
97 const SkPoint* getBottomPoints() { return fBottom.getPoints(); } | |
98 | |
99 void setData(); | |
100 | |
101 int getVertexCount() { return fVertCount; } | |
102 int getIndexCount() { return fIndexCount; } | |
103 SkPoint* getPoints() { return fPoints; } | |
104 SkPoint* getTexCoords() { return fTexCoords; } | |
105 uint32_t* getColors() { return fColors; } | |
106 uint16_t* getIndices() { return fIndices; } | |
107 | |
108 private: | |
109 SkPoint* fCtrlPoints; | |
110 SkFwDCubicEvaluator fBottom, fTop, fLeft, fRight; | |
111 SkPMColor fCornerColors[4]; | |
112 int fResX, fResY; | |
113 | |
114 int fVertCount, fIndexCount; | |
115 SkPoint* fPoints; | |
116 SkPoint* fTexCoords; | |
117 uint32_t* fColors; | |
118 uint16_t* fIndices; | |
119 bool fIsSet; | |
120 | |
121 typedef SkPatch INHERITED; | |
122 }; | |
123 | |
124 #endif | |
OLD | NEW |