diff options
author | Mike Reed <reed@google.com> | 2017-03-14 12:04:16 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-03-14 16:57:49 +0000 |
commit | 97eb4feb112967ba7fcb00d6995adda1002873c2 (patch) | |
tree | 4fb8569365aabaac2b2ef0d3cee88e4b9e7a4fdf /fuzz/FuzzCanvas.cpp | |
parent | 8f7d9b9784fc22b809ef1d2fa301b7b95efd2a90 (diff) |
add SkVertices::Builder
Possible next iterations:
- remove another allocation use the SkData trick to share
the object and its (trailing) data
- store a bit that tells use to free each pointer, allowing
the builder to "adopt" some allocations instead of copy.
Larger idea:
- merge with drawPoints to have a single object for both.
BUG=skia:6366
Change-Id: Iec33239aa2ad5d00b36469ca0b88934ddf6f22eb
Reviewed-on: https://skia-review.googlesource.com/9604
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'fuzz/FuzzCanvas.cpp')
-rw-r--r-- | fuzz/FuzzCanvas.cpp | 65 |
1 files changed, 5 insertions, 60 deletions
diff --git a/fuzz/FuzzCanvas.cpp b/fuzz/FuzzCanvas.cpp index 5189881f89..afd61a1c4b 100644 --- a/fuzz/FuzzCanvas.cpp +++ b/fuzz/FuzzCanvas.cpp @@ -1727,68 +1727,13 @@ static void fuzz_canvas(Fuzz* fuzz, SkCanvas* canvas, int depth = 9) { blendMode, indexCount > 0 ? indices : nullptr, indexCount, paint); } else { - std::unique_ptr<SkPoint[]> verticesUp(new SkPoint[vertexCount]); - memcpy(verticesUp.get(), vertices, sizeof(SkPoint) * vertexCount); - std::unique_ptr<SkColor[]> colorsUp; - if (useColors) { - colorsUp.reset(new SkColor[vertexCount]); - memcpy(colorsUp.get(), colors, sizeof(SkColor) * vertexCount); - } - std::unique_ptr<SkPoint[]> texsUp; - if (useTexs) { - texsUp.reset(new SkPoint[vertexCount]); - memcpy(texsUp.get(), texs, sizeof(SkPoint) * vertexCount); - } - std::unique_ptr<uint16_t[]> indicesUp; - if (indexCount > 0) { - indicesUp.reset(new uint16_t[indexCount]); - memcpy(indicesUp.get(), indices, sizeof(uint16_t) * indexCount); - } - SkRect bounds; - bool useBounds = false; - fuzz->next(&useBounds); - if (useBounds) { - bounds.setBounds(vertices, vertexCount); - } - sk_sp<SkVertices> verticesObj; - if (indexCount == 0) { - if (useBounds) { - verticesObj = SkVertices::Make(vertexMode, - std::move(verticesUp), - std::move(colorsUp), - std::move(texsUp), - vertexCount, - bounds); - } else { - verticesObj = SkVertices::Make(vertexMode, - std::move(verticesUp), - std::move(colorsUp), - std::move(texsUp), - vertexCount); - } - } else { - if (useBounds) { - verticesObj = SkVertices::MakeIndexed(vertexMode, - std::move(verticesUp), - std::move(colorsUp), - std::move(texsUp), - vertexCount, - std::move(indicesUp), - indexCount, - bounds); - } else { - verticesObj = SkVertices::MakeIndexed(vertexMode, - std::move(verticesUp), - std::move(colorsUp), - std::move(texsUp), - vertexCount, - std::move(indicesUp), - indexCount); - } - } uint32_t flags; fuzz->nextRange(&flags, 0, 3); - canvas->drawVertices(std::move(verticesObj), blendMode, paint, flags); + canvas->drawVertices(SkVertices::MakeCopy(vertexMode, vertexCount, vertices, + useTexs ? texs : nullptr, + useColors ? colors : nullptr, + indexCount, indices), + blendMode, paint, flags); } break; } |