Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 | |
| 80 // size in pixels of each partition per axis, adjust this knob | |
| 81 static const int kPartitionSize = 10; | |
|
bsalomon
2014/08/01 13:30:27
Does this really belong in the public interface of
dandov
2014/08/01 15:11:13
moved it to SkPatchUtils
| |
| 82 | |
| 71 /** | 83 /** |
| 72 * Points are in the following order: | 84 * Points are in the following order: |
| 73 * (top curve) | 85 * (top curve) |
| 74 * 0 1 2 3 | 86 * 0 1 2 3 |
| 75 * (left curve) 11 4 (right curve) | 87 * (left curve) 11 4 (right curve) |
| 76 * 10 5 | 88 * 10 5 |
| 77 * 9 8 7 6 | 89 * 9 8 7 6 |
| 78 * (bottom curve) | 90 * (bottom curve) |
| 79 * Used pointer to an array to guarantee that this method receives an array of 4 SkColors | |
| 80 */ | 91 */ |
| 81 SkPatch(SkPoint points[12], SkColor colors[4]); | 92 SkPatch(SkPoint points[12], SkColor colors[4]); |
| 82 | 93 |
| 83 /** | 94 /** |
| 84 * Function that evaluates the coons patch interpolation. | 95 * 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. | 96 * 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 | 97 * lod refers the level of detail for each axis. |
| 87 * axis. | |
| 88 */ | 98 */ |
| 89 bool getVertexData(SkPatch::VertexData* data, int divisions); | 99 bool getVertexData(SkPatch::VertexData* data, int lodX, int lodY) const; |
| 90 | 100 |
| 91 void getTopPoints(SkPoint points[4]) { | 101 void getTopPoints(SkPoint points[4]) const { |
| 92 points[0] = fCtrlPoints[kTopP0_CubicCtrlPts]; | 102 points[0] = fCtrlPoints[kTopP0_CubicCtrlPts]; |
| 93 points[1] = fCtrlPoints[kTopP1_CubicCtrlPts]; | 103 points[1] = fCtrlPoints[kTopP1_CubicCtrlPts]; |
| 94 points[2] = fCtrlPoints[kTopP2_CubicCtrlPts]; | 104 points[2] = fCtrlPoints[kTopP2_CubicCtrlPts]; |
| 95 points[3] = fCtrlPoints[kTopP3_CubicCtrlPts]; | 105 points[3] = fCtrlPoints[kTopP3_CubicCtrlPts]; |
| 96 } | 106 } |
| 97 | 107 |
| 98 void getBottomPoints(SkPoint points[4]) { | 108 void getBottomPoints(SkPoint points[4]) const { |
| 99 points[0] = fCtrlPoints[kBottomP0_CubicCtrlPts]; | 109 points[0] = fCtrlPoints[kBottomP0_CubicCtrlPts]; |
| 100 points[1] = fCtrlPoints[kBottomP1_CubicCtrlPts]; | 110 points[1] = fCtrlPoints[kBottomP1_CubicCtrlPts]; |
| 101 points[2] = fCtrlPoints[kBottomP2_CubicCtrlPts]; | 111 points[2] = fCtrlPoints[kBottomP2_CubicCtrlPts]; |
| 102 points[3] = fCtrlPoints[kBottomP3_CubicCtrlPts]; | 112 points[3] = fCtrlPoints[kBottomP3_CubicCtrlPts]; |
| 103 } | 113 } |
| 104 | 114 |
| 105 void getLeftPoints(SkPoint points[4]) { | 115 void getLeftPoints(SkPoint points[4]) const { |
| 106 points[0] = fCtrlPoints[kLeftP0_CubicCtrlPts]; | 116 points[0] = fCtrlPoints[kLeftP0_CubicCtrlPts]; |
| 107 points[1] = fCtrlPoints[kLeftP1_CubicCtrlPts]; | 117 points[1] = fCtrlPoints[kLeftP1_CubicCtrlPts]; |
| 108 points[2] = fCtrlPoints[kLeftP2_CubicCtrlPts]; | 118 points[2] = fCtrlPoints[kLeftP2_CubicCtrlPts]; |
| 109 points[3] = fCtrlPoints[kLeftP3_CubicCtrlPts]; | 119 points[3] = fCtrlPoints[kLeftP3_CubicCtrlPts]; |
| 110 } | 120 } |
| 111 | 121 |
| 112 void getRightPoints(SkPoint points[4]) { | 122 void getRightPoints(SkPoint points[4]) const { |
| 113 points[0] = fCtrlPoints[kRightP0_CubicCtrlPts]; | 123 points[0] = fCtrlPoints[kRightP0_CubicCtrlPts]; |
| 114 points[1] = fCtrlPoints[kRightP1_CubicCtrlPts]; | 124 points[1] = fCtrlPoints[kRightP1_CubicCtrlPts]; |
| 115 points[2] = fCtrlPoints[kRightP2_CubicCtrlPts]; | 125 points[2] = fCtrlPoints[kRightP2_CubicCtrlPts]; |
| 116 points[3] = fCtrlPoints[kRightP3_CubicCtrlPts]; | 126 points[3] = fCtrlPoints[kRightP3_CubicCtrlPts]; |
| 117 } | 127 } |
| 118 | 128 |
| 129 void getCornerPoints(SkPoint points[4]) const { | |
| 130 points[0] = fCtrlPoints[kTopP0_CubicCtrlPts]; | |
| 131 points[1] = fCtrlPoints[kTopP3_CubicCtrlPts]; | |
| 132 points[2] = fCtrlPoints[kBottomP3_CubicCtrlPts]; | |
| 133 points[3] = fCtrlPoints[kBottomP0_CubicCtrlPts]; | |
| 134 } | |
| 135 | |
| 136 const SkPoint* getControlPoints() const { | |
| 137 return fCtrlPoints; | |
| 138 } | |
| 139 | |
| 140 const SkColor* getColors() const { | |
| 141 return fCornerColors; | |
| 142 } | |
| 143 | |
| 119 private: | 144 private: |
| 120 SkPoint fCtrlPoints[12]; | 145 SkPoint fCtrlPoints[12]; |
| 121 SkPMColor fCornerColors[4]; | 146 SkColor fCornerColors[4]; |
| 122 }; | 147 }; |
| 123 | 148 |
| 124 #endif | 149 #endif |
| OLD | NEW |