Chromium Code Reviews| 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 |