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

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

Issue 405163003: SkPatch abstraction (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Enum for control points 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
(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 "SkPreConfig.h"
13 #include "SkPoint.h"
14
15 /**
16 * Class that represents a coons patch.
17 */
18 class SK_API SkPatch {
19
20 public:
21 /**
22 * Structure that holds the vertex data related to the tessellation of a SkP atch. It is passed
23 * as a parameter to the function getVertexData.
bsalomon 2014/07/25 14:16:37 "The generated arrays can be used with SkCanvas::d
dandov 2014/07/25 15:07:09 The idea is to add a SkCanvas::drawPatch.
24 */
25 struct PatchData {
26 int fVertexCount, fIndexCount;
27 SkPoint* fPoints;
28 SkPoint* fTexCoords;
29 uint32_t* fColors;
30 uint16_t* fIndices;
31
32 PatchData()
33 : fVertexCount(0)
34 , fIndexCount(0)
35 , fPoints(NULL)
36 , fTexCoords(NULL)
37 , fColors(NULL)
38 , fIndices(NULL) { }
39
40 ~PatchData() {
41 SkDELETE_ARRAY(fPoints);
42 SkDELETE_ARRAY(fTexCoords);
43 SkDELETE_ARRAY(fColors);
44 SkDELETE_ARRAY(fIndices);
45 }
46 };
47
48 enum SkCubicCtrlPts {
egdaniel 2014/07/25 14:49:27 Remove the Sk since we are already inside of SkPat
dandov 2014/07/25 15:07:09 Done.
49 kTopP0_CubicCtrlPts=0,
egdaniel 2014/07/25 14:49:26 Nit space around =
dandov 2014/07/25 15:07:09 Done.
50 kTopP1_CubicCtrlPts=1,
51 kTopP2_CubicCtrlPts=2,
52 kTopP3_CubicCtrlPts=3,
53
54 kRightP0_CubicCtrlPts=3,
55 kRightP1_CubicCtrlPts=4,
56 kRightP2_CubicCtrlPts=5,
57 kRightP3_CubicCtrlPts=6,
58
59 kBottomP0_CubicCtrlPts=9,
60 kBottomP1_CubicCtrlPts=8,
61 kBottomP2_CubicCtrlPts=7,
62 kBottomP3_CubicCtrlPts=6,
63
64 kLeftP0_CubicCtrlPts=0,
65 kLeftP1_CubicCtrlPts=11,
66 kLeftP2_CubicCtrlPts=10,
67 kLeftP3_CubicCtrlPts=9,
68 };
69
70 /**
71 * Points are in the following order:
72 * (top curve)
73 * 0 1 2 3
74 * (left curve) 11 4 (right curve)
75 * 10 5
76 * 9 8 7 6
77 * (bottom curve)
78 * Used pointer to an array to guarantee that this method receives an array of 4 SkColors
79 */
80 SkPatch(SkPoint points[12], SkColor colors[4]);
81
82 bool getVertexData(SkPatch::PatchData* data, int divisions);
bsalomon 2014/07/25 14:16:37 Comment about what divisions means?
dandov 2014/07/25 15:07:09 Done.
83
84 void getTopPoints(SkPoint points[4]) {
85 points[0] = fCtrlPoints[kTopP0_CubicCtrlPts];
86 points[1] = fCtrlPoints[kTopP1_CubicCtrlPts];
87 points[2] = fCtrlPoints[kTopP2_CubicCtrlPts];
88 points[3] = fCtrlPoints[kTopP3_CubicCtrlPts];
89 }
90
91 const void getBottomPoints(SkPoint points[4]) {
92 points[0] = fCtrlPoints[kBottomP0_CubicCtrlPts];
93 points[1] = fCtrlPoints[kBottomP1_CubicCtrlPts];
94 points[2] = fCtrlPoints[kBottomP2_CubicCtrlPts];
95 points[3] = fCtrlPoints[kBottomP3_CubicCtrlPts];
96 }
97
98 const void getLeftPoints(SkPoint points[4]) {
99 points[0] = fCtrlPoints[kLeftP0_CubicCtrlPts];
100 points[1] = fCtrlPoints[kLeftP1_CubicCtrlPts];
101 points[2] = fCtrlPoints[kLeftP2_CubicCtrlPts];
102 points[3] = fCtrlPoints[kLeftP3_CubicCtrlPts];
103 }
104
105 const void getRightPoints(SkPoint points[4]) {
106 points[0] = fCtrlPoints[kRightP0_CubicCtrlPts];
107 points[1] = fCtrlPoints[kRightP1_CubicCtrlPts];
108 points[2] = fCtrlPoints[kRightP2_CubicCtrlPts];
109 points[3] = fCtrlPoints[kRightP3_CubicCtrlPts];
110 }
111
112 private:
113 SkPoint fCtrlPoints[12];
114 SkPMColor fCornerColors[4];
115 };
116
117 #endif
OLDNEW
« no previous file with comments | « gm/patch.cpp ('k') | src/core/SkPatch.cpp » ('j') | src/core/SkPatch.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698