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

Unified 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: Dumped corners and colors and used enum for 12's and 4's 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 side-by-side diff with in-line comments
Download patch
Index: include/core/SkPatch.h
diff --git a/include/core/SkPatch.h b/include/core/SkPatch.h
index 3e06c3fc91f9ce5bf5df56d2da680f8cefc36068..79606d89bee5a4ad8edde162fc3ae76d59878104 100644
--- a/include/core/SkPatch.h
+++ b/include/core/SkPatch.h
@@ -77,6 +77,12 @@ public:
kBottomLeft_CornerColors
};
+ enum {
+ kNumCtrlPts = 12,
+ kNumColors = 4,
+ kNumPtsCubic = 4
+ };
+
/**
* Points are in the following order:
* (top curve)
@@ -86,7 +92,8 @@ public:
* 9 8 7 6
* (bottom curve)
*/
- SkPatch(SkPoint points[12], SkColor colors[4]);
+ SkPatch() { }
+ SkPatch(const SkPoint points[kNumCtrlPts], const SkColor colors[kNumColors]);
/**
* Function that evaluates the coons patch interpolation.
@@ -95,35 +102,35 @@ public:
*/
bool getVertexData(SkPatch::VertexData* data, int lodX, int lodY) const;
- void getTopPoints(SkPoint points[4]) const {
+ void getTopPoints(SkPoint points[kNumPtsCubic]) const {
points[0] = fCtrlPoints[kTopP0_CubicCtrlPts];
points[1] = fCtrlPoints[kTopP1_CubicCtrlPts];
points[2] = fCtrlPoints[kTopP2_CubicCtrlPts];
points[3] = fCtrlPoints[kTopP3_CubicCtrlPts];
}
- void getBottomPoints(SkPoint points[4]) const {
+ void getBottomPoints(SkPoint points[kNumPtsCubic]) const {
points[0] = fCtrlPoints[kBottomP0_CubicCtrlPts];
points[1] = fCtrlPoints[kBottomP1_CubicCtrlPts];
points[2] = fCtrlPoints[kBottomP2_CubicCtrlPts];
points[3] = fCtrlPoints[kBottomP3_CubicCtrlPts];
}
- void getLeftPoints(SkPoint points[4]) const {
+ void getLeftPoints(SkPoint points[kNumPtsCubic]) const {
points[0] = fCtrlPoints[kLeftP0_CubicCtrlPts];
points[1] = fCtrlPoints[kLeftP1_CubicCtrlPts];
points[2] = fCtrlPoints[kLeftP2_CubicCtrlPts];
points[3] = fCtrlPoints[kLeftP3_CubicCtrlPts];
}
- void getRightPoints(SkPoint points[4]) const {
+ void getRightPoints(SkPoint points[kNumPtsCubic]) const {
points[0] = fCtrlPoints[kRightP0_CubicCtrlPts];
points[1] = fCtrlPoints[kRightP1_CubicCtrlPts];
points[2] = fCtrlPoints[kRightP2_CubicCtrlPts];
points[3] = fCtrlPoints[kRightP3_CubicCtrlPts];
}
robertphillips 2014/08/05 12:44:45 Not sure about this use of kNumPtsCubic. This coul
dandov 2014/08/05 14:27:11 Done.
- void getCornerPoints(SkPoint points[4]) const {
+ void getCornerPoints(SkPoint points[kNumPtsCubic]) const {
points[0] = fCtrlPoints[kTopP0_CubicCtrlPts];
points[1] = fCtrlPoints[kTopP3_CubicCtrlPts];
points[2] = fCtrlPoints[kBottomP3_CubicCtrlPts];
@@ -138,9 +145,39 @@ public:
return fCornerColors;
}
+ void setPoints(const SkPoint points[kNumCtrlPts]) {
+ memcpy(fCtrlPoints, points, kNumCtrlPts * sizeof(SkPoint));
+
+ }
+
+ void setColors(const SkColor colors[kNumColors]) {
+ memcpy(fCornerColors, colors, kNumColors * sizeof(SkColor));
+ }
+
+ void reset(const SkPoint points[kNumCtrlPts], const SkColor colors[kNumColors]) {
+ this->setPoints(points);
+ this->setColors(colors);
+ }
+
+ /**
+ * Write the patch to the buffer, and return the number of bytes written.
+ * If buffer is NULL, it still returns the number of bytes.
+ */
+ size_t writeToMemory(void* buffer) const;
+
+ /**
+ * Initializes the patch from the buffer
+ *
+ * buffer Memory to read from
+ * length Amount of memory available in the buffer
robertphillips 2014/08/05 12:44:45 Add a "Returns" before "number" ?
dandov 2014/08/05 14:27:11 Done.
+ * number of bytes read (must be a multiple of 4) or
+ * 0 if there was not enough memory available
+ */
+ size_t readFromMemory(const void* buffer, size_t length);
+
private:
- SkPoint fCtrlPoints[12];
- SkColor fCornerColors[4];
+ SkPoint fCtrlPoints[kNumCtrlPts];
+ SkColor fCornerColors[kNumColors];
};
#endif

Powered by Google App Engine
This is Rietveld 408576698