diff options
Diffstat (limited to 'src/core/SkPictureRecord.cpp')
-rw-r--r-- | src/core/SkPictureRecord.cpp | 66 |
1 files changed, 19 insertions, 47 deletions
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp index 98677dd5eb..1639cff863 100644 --- a/src/core/SkPictureRecord.cpp +++ b/src/core/SkPictureRecord.cpp @@ -722,59 +722,26 @@ void SkPictureRecord::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matri } void SkPictureRecord::onDrawVertices(VertexMode vmode, int vertexCount, - const SkPoint vertices[], const SkPoint texs[], - const SkColor colors[], SkBlendMode bmode, + const SkPoint pos[], const SkPoint texs[], + const SkColor cols[], SkBlendMode bmode, const uint16_t indices[], int indexCount, const SkPaint& paint) { - uint32_t flags = 0; - if (texs) { - flags |= DRAW_VERTICES_HAS_TEXS; - } - if (colors) { - flags |= DRAW_VERTICES_HAS_COLORS; - } - if (indexCount > 0) { - flags |= DRAW_VERTICES_HAS_INDICES; - } - if (SkBlendMode::kModulate != bmode) { - flags |= DRAW_VERTICES_HAS_XFER; + auto vertices = SkVertices::MakeCopy(vmode, vertexCount, pos, texs, cols, indexCount, indices); + if (vertices) { + this->onDrawVerticesObject(vertices.get(), bmode, paint); } +} - // op + paint index + flags + vmode + vCount + vertices - size_t size = 5 * kUInt32Size + vertexCount * sizeof(SkPoint); - if (flags & DRAW_VERTICES_HAS_TEXS) { - size += vertexCount * sizeof(SkPoint); // + uvs - } - if (flags & DRAW_VERTICES_HAS_COLORS) { - size += vertexCount * sizeof(SkColor); // + vert colors - } - if (flags & DRAW_VERTICES_HAS_INDICES) { - // + num indices + indices - size += 1 * kUInt32Size + SkAlign4(indexCount * sizeof(uint16_t)); - } - if (flags & DRAW_VERTICES_HAS_XFER) { - size += kUInt32Size; // mode enum - } +void SkPictureRecord::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode, + const SkPaint& paint) { + // op + paint index + vertices index + mode + size_t size = 4 * kUInt32Size; + size_t initialOffset = this->addDraw(DRAW_VERTICES_OBJECT, &size); - size_t initialOffset = this->addDraw(DRAW_VERTICES, &size); this->addPaint(paint); - this->addInt(flags); - this->addInt(vmode); - this->addInt(vertexCount); - this->addPoints(vertices, vertexCount); - if (flags & DRAW_VERTICES_HAS_TEXS) { - this->addPoints(texs, vertexCount); - } - if (flags & DRAW_VERTICES_HAS_COLORS) { - fWriter.writeMul4(colors, vertexCount * sizeof(SkColor)); - } - if (flags & DRAW_VERTICES_HAS_INDICES) { - this->addInt(indexCount); - fWriter.writePad(indices, indexCount * sizeof(uint16_t)); - } - if (flags & DRAW_VERTICES_HAS_XFER) { - this->addInt((int)bmode); - } + this->addVertices(vertices); + this->addInt(static_cast<uint32_t>(mode)); + this->validate(initialOffset, size); } @@ -984,4 +951,9 @@ void SkPictureRecord::addTextBlob(const SkTextBlob* blob) { this->addInt(find_or_append_uniqueID(fTextBlobRefs, blob) + 1); } +void SkPictureRecord::addVertices(const SkVertices* vertices) { + // follow the convention of recording a 1-based index + this->addInt(find_or_append_uniqueID(fVerticesRefs, vertices) + 1); +} + /////////////////////////////////////////////////////////////////////////////// |