Index: src/core/SkPictureRecord.cpp |
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp |
index d9239ddcca2db9d487c82958a67835da1dc19a22..dbae9fa69675d1ea477d18e915fc9f415d84462e 100644 |
--- a/src/core/SkPictureRecord.cpp |
+++ b/src/core/SkPictureRecord.cpp |
@@ -6,12 +6,13 @@ |
*/ |
#include "SkPictureRecord.h" |
-#include "SkTSearch.h" |
-#include "SkPixelRef.h" |
-#include "SkRRect.h" |
#include "SkBBoxHierarchy.h" |
#include "SkDevice.h" |
+#include "SkPatchUtils.h" |
#include "SkPictureStateTree.h" |
+#include "SkPixelRef.h" |
+#include "SkRRect.h" |
+#include "SkTSearch.h" |
#define HEAP_BLOCK_SIZE 4096 |
@@ -1269,14 +1270,46 @@ void SkPictureRecord::drawVertices(VertexMode vmode, int vertexCount, |
this->validate(initialOffset, size); |
} |
-void SkPictureRecord::drawPatch(const SkPatch& patch, const SkPaint& paint) { |
- // op + paint index + patch 12 control points + patch 4 colors |
- size_t size = 2 * kUInt32Size + SkPatch::kNumCtrlPts * sizeof(SkPoint) + |
- SkPatch::kNumColors * sizeof(SkColor); |
+void SkPictureRecord::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], |
+ const SkPoint texCoords[4], SkXfermode* xmode, |
+ const SkPaint& paint) { |
+ // op + paint index + patch 12 control points + flag + patch 4 colors + 4 texture coordinates |
+ size_t size = 2 * kUInt32Size + SkPatchUtils::kNumCtrlPts * sizeof(SkPoint) + kUInt32Size; |
+ uint32_t flag = 0; |
+ if (NULL != colors) { |
+ flag |= DRAW_VERTICES_HAS_COLORS; |
+ size += SkPatchUtils::kNumCorners * sizeof(SkColor); |
+ } |
+ if (NULL != texCoords) { |
+ flag |= DRAW_VERTICES_HAS_TEXS; |
+ size += SkPatchUtils::kNumCorners * sizeof(SkPoint); |
+ } |
+ if (NULL != xmode) { |
+ SkXfermode::Mode mode; |
+ if (xmode->asMode(&mode) && SkXfermode::kModulate_Mode != mode) { |
+ flag |= DRAW_VERTICES_HAS_XFER; |
+ size += kUInt32Size; |
+ } |
+ } |
+ |
size_t initialOffset = this->addDraw(DRAW_PATCH, &size); |
SkASSERT(initialOffset+getPaintOffset(DRAW_PATCH, size) == fWriter.bytesWritten()); |
this->addPaint(paint); |
- this->addPatch(patch); |
+ this->addPatch(cubics); |
+ this->addInt(flag); |
+ |
+ // write optional parameters |
+ if (NULL != colors) { |
+ fWriter.write(colors, SkPatchUtils::kNumCorners * sizeof(SkColor)); |
+ } |
+ if (NULL != texCoords) { |
+ fWriter.write(texCoords, SkPatchUtils::kNumCorners * sizeof(SkPoint)); |
+ } |
+ if (flag & DRAW_VERTICES_HAS_XFER) { |
+ SkXfermode::Mode mode = SkXfermode::kModulate_Mode; |
+ xmode->asMode(&mode); |
+ this->addInt(mode); |
+ } |
this->validate(initialOffset, size); |
} |
@@ -1406,8 +1439,8 @@ void SkPictureRecord::addPath(const SkPath& path) { |
this->addInt(this->addPathToHeap(path)); |
} |
-void SkPictureRecord::addPatch(const SkPatch& patch) { |
- fWriter.writePatch(patch); |
+void SkPictureRecord::addPatch(const SkPoint cubics[12]) { |
+ fWriter.write(cubics, SkPatchUtils::kNumCtrlPts * sizeof(SkPoint)); |
} |
void SkPictureRecord::addPicture(const SkPicture* picture) { |