Index: src/core/SkPictureRecord.cpp |
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp |
index 66aa46d14bab632c606e058fb8224fb722961e1e..9faed9c432cee3db3c8de7ac10f36ddc1fe938d4 100644 |
--- a/src/core/SkPictureRecord.cpp |
+++ b/src/core/SkPictureRecord.cpp |
@@ -1480,18 +1480,54 @@ void SkPictureRecord::drawVertices(VertexMode vmode, int vertexCount, |
this->validate(initialOffset, size); |
} |
-void SkPictureRecord::drawPatch(const SkPatch& patch, const SkPaint& paint) { |
+void SkPictureRecord::drawPatch(const SkPoint cubics[12], const SkColor colors[4], |
+ const SkPoint texCoords[4], SkXfermode* xmode, |
+ const SkPaint& paint) { |
+ if (NULL == cubics) { |
+ return; |
+ } |
+ |
#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); |
#endif |
- // op + paint index + patch 12 control points + patch 4 colors |
- size_t size = 2 * kUInt32Size + SkPatch::kNumCtrlPts * sizeof(SkPoint) + |
- SkPatch::kNumColors * sizeof(SkColor); |
+ // op + paint index + patch 12 control points + flag + patch 4 colors + 4 texture coordinates |
+ size_t size = 2 * kUInt32Size + SkPatch::kNumCtrlPts * sizeof(SkPoint) + kUInt32Size; |
+ uint32_t flag = 0; |
+ if (NULL != colors) { |
+ flag |= DRAW_VERTICES_HAS_COLORS; |
+ size += SkPatch::kNumCorners * sizeof(SkColor); |
+ } |
+ if (NULL != texCoords) { |
+ flag |= DRAW_VERTICES_HAS_TEXS; |
+ size += SkPatch::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, SkPatch::kNumCorners * sizeof(SkColor)); |
+ } |
+ if (NULL != texCoords) { |
+ fWriter.write(texCoords, SkPatch::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); |
} |
@@ -1626,8 +1662,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, SkPatch::kNumCtrlPts * sizeof(SkPoint)); |
} |
void SkPictureRecord::addPicture(const SkPicture* picture) { |