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

Unified Diff: src/core/SkPictureRecord.cpp

Issue 463493002: SkCanvas::drawPatch param SkPoint[12] (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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
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) {

Powered by Google App Engine
This is Rietveld 408576698