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

Unified Diff: include/core/SkPatch.h

Issue 405163003: SkPatch abstraction (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Moved ownership of vertex data out of SkPatch Created 6 years, 5 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
« no previous file with comments | « gm/patch.cpp ('k') | src/core/SkPatch.cpp » ('j') | src/core/SkPatch.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkPatch.h
diff --git a/include/core/SkPatch.h b/include/core/SkPatch.h
new file mode 100644
index 0000000000000000000000000000000000000000..63b7f93c8ba8ee485190b7db244cb567bd451bbd
--- /dev/null
+++ b/include/core/SkPatch.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkPatch_DEFINED
+#define SkPatch_DEFINED
+
+#include "SkColor.h"
+#include "SkPoint.h"
+
+/**
+ * Class that represents a coons patch.
+ */
+class SK_API SkPatch {
+
+public:
+
+ 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.
+ int fVertCount, fIndexCount;
+ SkPoint* fPoints;
+ SkPoint* fTexCoords;
+ uint32_t* fColors;
+ uint16_t* fIndices;
+
+ PatchData()
+ : fVertCount(0)
+ , fIndexCount(0)
+ , fPoints(NULL)
+ , fTexCoords(NULL)
+ , fColors(NULL)
+ , fIndices(NULL) { }
+
+ ~PatchData() {
+ SkDELETE_ARRAY(fPoints);
+ SkDELETE_ARRAY(fTexCoords);
+ SkDELETE_ARRAY(fColors);
+ SkDELETE_ARRAY(fIndices);
+ }
+ };
+
+ /**
+ * Points are in the following order:
+ * (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
+ * 0 1 2 3
+ * (left curve) 11 4 (right curve)
+ * 10 5
+ * 9 8 7 6
+ * (top curve)
+ * Used pointer to an array to guarantee that this method receives an array of 4 SkColors
+ */
+ SkPatch(SkPoint points[12], SkColor colors[4], int res);
+
+ void getVertexData(SkPatch::PatchData* data);
+
+ void getBottomPoints(SkPoint points[4]) {
+ points[0] = fCtrlPoints[0];
+ points[1] = fCtrlPoints[1];
+ points[2] = fCtrlPoints[2];
+ points[3] = fCtrlPoints[3];
+ }
+
+ 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.
+ points[0] = fCtrlPoints[9];
+ points[1] = fCtrlPoints[8];
+ points[2] = fCtrlPoints[7];
+ points[3] = fCtrlPoints[6];
+ }
+
+ const void getLeftPoints(SkPoint points[4]) {
+ points[0] = fCtrlPoints[0];
+ points[1] = fCtrlPoints[11];
+ points[2] = fCtrlPoints[10];
+ points[3] = fCtrlPoints[9];
+ }
+
+ const void getRightPoints(SkPoint points[4]) {
+ points[0] = fCtrlPoints[3];
+ points[1] = fCtrlPoints[4];
+ points[2] = fCtrlPoints[5];
+ points[3] = fCtrlPoints[6];
+ }
+
+
+private:
+ SkPoint fCtrlPoints[12];
+ SkPMColor fCornerColors[4];
+ int fDivX, fDivY;
+};
+
+#endif
« 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