diff options
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/ops/GrDrawVerticesOp.cpp | 39 |
1 files changed, 4 insertions, 35 deletions
diff --git a/src/gpu/ops/GrDrawVerticesOp.cpp b/src/gpu/ops/GrDrawVerticesOp.cpp index c79d9acf83..5d8837880f 100644 --- a/src/gpu/ops/GrDrawVerticesOp.cpp +++ b/src/gpu/ops/GrDrawVerticesOp.cpp @@ -15,46 +15,15 @@ std::unique_ptr<GrMeshDrawOp> GrDrawVerticesOp::Make( const SkPoint* positions, int vertexCount, const uint16_t* indices, int indexCount, const uint32_t* colors, const SkPoint* localCoords, const SkRect& bounds, GrRenderTargetContext::ColorArrayType colorArrayType) { + static constexpr SkCanvas::VertexMode kIgnoredMode = SkCanvas::kTriangles_VertexMode; SkASSERT(positions); - std::unique_ptr<SkPoint[]> pos(new SkPoint[vertexCount]); - memcpy(pos.get(), positions, sizeof(SkPoint) * vertexCount); - std::unique_ptr<SkColor[]> col; - if (colors) { - col.reset(new SkColor[vertexCount]); - memcpy(col.get(), colors, sizeof(SkColor) * vertexCount); - } else { + if (!colors) { // When we tessellate we will fill a color array with the GrColor value passed above as // 'color'. colorArrayType = GrRenderTargetContext::ColorArrayType::kPremulGrColor; } - std::unique_ptr<SkPoint[]> lc; - if (localCoords) { - lc.reset(new SkPoint[vertexCount]); - memcpy(lc.get(), localCoords, sizeof(SkPoint) * vertexCount); - } - std::unique_ptr<uint16_t[]> idx; - if (indexCount) { - idx.reset(new uint16_t[indexCount]); - memcpy(idx.get(), indices, sizeof(uint16_t) * indexCount); - } - static constexpr SkCanvas::VertexMode kIgnoredMode = SkCanvas::kTriangles_VertexMode; - sk_sp<SkVertices> vertices; - // Older libstdc++ does not allow moving a std::unique_ptr<T[]> into a - // std::unique_ptr<const T[]>. Hence the release() calls below. - if (indices) { - vertices = SkVertices::MakeIndexed( - kIgnoredMode, std::unique_ptr<const SkPoint[]>((const SkPoint*)pos.release()), - std::unique_ptr<const SkColor[]>((const SkColor*)col.release()), - std::unique_ptr<const SkPoint[]>((const SkPoint*)lc.release()), vertexCount, - std::unique_ptr<const uint16_t[]>((const uint16_t*)idx.release()), indexCount, - bounds); - } else { - vertices = SkVertices::Make(kIgnoredMode, - std::unique_ptr<const SkPoint[]>((const SkPoint*)pos.release()), - std::unique_ptr<const SkColor[]>((const SkColor*)col.release()), - std::unique_ptr<const SkPoint[]>((const SkPoint*)lc.release()), - vertexCount, bounds); - } + sk_sp<SkVertices> vertices = SkVertices::MakeCopy(kIgnoredMode, vertexCount, positions, + localCoords, colors, indexCount, indices); if (!vertices) { return nullptr; } |