diff options
author | 2017-03-17 13:09:38 +0000 | |
---|---|---|
committer | 2017-03-17 13:09:52 +0000 | |
commit | 1eb3fef136bc75bd8e8ed717ec7c5d4ab26def62 (patch) | |
tree | f58f12a44fbbb8bdd4727b923b587cc6d2c34c9d /src/core/SkPictureRecord.cpp | |
parent | 73e21af21390c2806eb1350253233903808edd6b (diff) |
Revert "More SkVertices implementation work"
This reverts commit 14583e11fd622c686993b741499060a6f3527055.
Reason for revert: leaking
Direct leak of 499104 byte(s) in 2112 object(s) allocated from:
#0 0x1e195f0 in operator new(unsigned long) (/b/swarm_slave/w/irazbR79/out/Debug/dm+0x1e195f0)
#1 0x3142b0a in SkVertices::Builder::init(SkCanvas::VertexMode, int, int, SkVertices::Sizes const&) (/b/swarm_slave/w/irazbR79/out/Debug/dm+0x3142b0a)
Original change's description:
> More SkVertices implementation work
>
> - change virtuals to take const SkVertices*, as we do for TextBobs and Images
> - override onDrawVerticesObject in recording canvases
> - deserialize raw-vertices into SkVertices object
>
> Possibly a follow-on would intercept the raw-form directly in canvas,
> and remove the virtual, and only support the object form.
>
> BUG=skia:6366
>
> Change-Id: I57a932667ccb3b3b004beb802ac3ae6898e3c6e0
> Reviewed-on: https://skia-review.googlesource.com/9633
> Commit-Queue: Mike Reed <reed@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
>
TBR=bsalomon@google.com,reed@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:6366
Change-Id: I40bb7a20698ef6aa0a9ef71a3d6ac4c1473e081c
Reviewed-on: https://skia-review.googlesource.com/9825
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src/core/SkPictureRecord.cpp')
-rw-r--r-- | src/core/SkPictureRecord.cpp | 66 |
1 files changed, 47 insertions, 19 deletions
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp index 1639cff863..98677dd5eb 100644 --- a/src/core/SkPictureRecord.cpp +++ b/src/core/SkPictureRecord.cpp @@ -722,26 +722,59 @@ void SkPictureRecord::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matri } void SkPictureRecord::onDrawVertices(VertexMode vmode, int vertexCount, - const SkPoint pos[], const SkPoint texs[], - const SkColor cols[], SkBlendMode bmode, + const SkPoint vertices[], const SkPoint texs[], + const SkColor colors[], SkBlendMode bmode, const uint16_t indices[], int indexCount, const SkPaint& paint) { - auto vertices = SkVertices::MakeCopy(vmode, vertexCount, pos, texs, cols, indexCount, indices); - if (vertices) { - this->onDrawVerticesObject(vertices.get(), bmode, 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; } -} -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); + // 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 + } + size_t initialOffset = this->addDraw(DRAW_VERTICES, &size); this->addPaint(paint); - this->addVertices(vertices); - this->addInt(static_cast<uint32_t>(mode)); - + 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->validate(initialOffset, size); } @@ -951,9 +984,4 @@ 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); -} - /////////////////////////////////////////////////////////////////////////////// |