| Index: src/core/SkPatch.cpp
|
| diff --git a/src/core/SkPatch.cpp b/src/core/SkPatch.cpp
|
| index cc967d5ceece7d1698cbc0648c2f1ae39fc22b0c..382580c77270cff744ce2d6752df590390133e34 100644
|
| --- a/src/core/SkPatch.cpp
|
| +++ b/src/core/SkPatch.cpp
|
| @@ -9,6 +9,7 @@
|
|
|
| #include "SkGeometry.h"
|
| #include "SkColorPriv.h"
|
| +#include "SkBuffer.h"
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| @@ -117,15 +118,8 @@ private:
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| -SkPatch::SkPatch(SkPoint points[12], SkColor colors[4]) {
|
| -
|
| - for (int i = 0; i < 12; i++) {
|
| - fCtrlPoints[i] = points[i];
|
| - }
|
| - for (int i = 0; i < 4; i++) {
|
| - fCornerColors[i] = colors[i];
|
| - }
|
| -
|
| +SkPatch::SkPatch(const SkPoint points[12], const SkColor colors[4]) {
|
| + this->reset(points, colors);
|
| }
|
|
|
| uint8_t bilinear(SkScalar tx, SkScalar ty, SkScalar c00, SkScalar c10, SkScalar c01, SkScalar c11) {
|
| @@ -236,3 +230,37 @@ bool SkPatch::getVertexData(SkPatch::VertexData* data, int lodX, int lodY) const
|
| }
|
| return true;
|
| }
|
| +
|
| +size_t SkPatch::writeToMemory(void* storage) const {
|
| + int byteCount = kNumCtrlPts * sizeof(SkPoint) + kNumColors * sizeof(SkColor);
|
| +
|
| + if (NULL == storage) {
|
| + return SkAlign4(byteCount);
|
| + }
|
| +
|
| + SkWBuffer buffer(storage);
|
| +
|
| + buffer.write(fCtrlPoints, kNumCtrlPts * sizeof(SkPoint));
|
| + buffer.write(fCornerColors, kNumColors * sizeof(SkColor));
|
| +
|
| + buffer.padToAlign4();
|
| + return buffer.pos();
|
| +}
|
| +
|
| +size_t SkPatch::readFromMemory(const void* storage, size_t length) {
|
| + SkRBufferWithSizeCheck buffer(storage, length);
|
| +
|
| + int byteCount = 0;
|
| +
|
| + if (!buffer.read(fCtrlPoints, kNumCtrlPts * sizeof(SkPoint))) {
|
| + return byteCount;
|
| + }
|
| + byteCount += kNumCtrlPts * sizeof(SkPoint);
|
| +
|
| + if (!buffer.read(fCornerColors, kNumColors * sizeof(SkColor))) {
|
| + return byteCount;
|
| + }
|
| + byteCount += kNumColors * sizeof(SkColor);
|
| +
|
| + return byteCount;
|
| +}
|
|
|