diff options
author | Brian Salomon <bsalomon@google.com> | 2017-02-06 14:11:51 -0500 |
---|---|---|
committer | Brian Salomon <bsalomon@google.com> | 2017-02-06 19:59:02 +0000 |
commit | 604c9890cc55a150591ae52fe0c34e759d6a5ebb (patch) | |
tree | c67cf791b82785f6df467a4d19b2e85330ed08de | |
parent | 8a945603e44d8a9fdb2004231c76a41a22f9b6ff (diff) |
Work around broken std::unique_ptr<const T[]> constructor from std::unique_ptr<T>&& in older libstdc++.
Change-Id: Ie4190800369515168203ff98b3e3fe0e2d790f1a
Reviewed-on: https://skia-review.googlesource.com/8072
Reviewed-by: Robert Phillips <robertphillips@google.com>
-rw-r--r-- | gm/vertices.cpp | 24 | ||||
-rw-r--r-- | src/gpu/ops/GrDrawVerticesOp.cpp | 16 |
2 files changed, 26 insertions, 14 deletions
diff --git a/gm/vertices.cpp b/gm/vertices.cpp index 5fdce92a8e..2ca492684c 100644 --- a/gm/vertices.cpp +++ b/gm/vertices.cpp @@ -100,10 +100,14 @@ protected: memcpy(colors.get(), fColors, sizeof(SkColor) * kMeshVertexCnt); memcpy(texs.get(), fTexs, sizeof(SkPoint) * kMeshVertexCnt); memcpy(indices.get(), kMeshFan, sizeof(uint16_t) * kMeshIndexCnt); - fVertices = SkVertices::MakeIndexed(SkCanvas::kTriangleFan_VertexMode, - std::move(points), - std::move(colors), std::move(texs), kMeshVertexCnt, - std::move(indices), kMeshIndexCnt); + // Older libstdc++ does not allow moving a std::unique_ptr<T[]> into a + // std::unique_ptr<const T[]>. Hence the release() calls below. + fVertices = SkVertices::MakeIndexed( + SkCanvas::kTriangleFan_VertexMode, + std::unique_ptr<const SkPoint[]>(points.release()), + std::unique_ptr<const SkColor[]>(colors.release()), + std::unique_ptr<const SkPoint[]>(texs.release()), kMeshVertexCnt, + std::unique_ptr<const uint16_t[]>(indices.release()), kMeshIndexCnt); } } @@ -230,11 +234,13 @@ static void draw_batching(SkCanvas* canvas, bool useObject) { sk_sp<SkVertices> vertices; if (useObject) { - vertices = - SkVertices::MakeIndexed(SkCanvas::kTriangles_VertexMode, std::move(pts), - std::move(colors), - std::move(texs), kMeshVertexCnt, std::move(indices), - 3 * kNumTris); + // Older libstdc++ does not allow moving a std::unique_ptr<T[]> into a + // std::unique_ptr<const T[]>. Hence the release() calls below. + vertices = SkVertices::MakeIndexed( + SkCanvas::kTriangles_VertexMode, std::unique_ptr<const SkPoint[]>(pts.release()), + std::unique_ptr<const SkColor[]>(colors.release()), + std::unique_ptr<const SkPoint[]>(texs.release()), kMeshVertexCnt, + std::unique_ptr<const uint16_t[]>(indices.release()), 3 * kNumTris); } canvas->save(); canvas->translate(10, 10); diff --git a/src/gpu/ops/GrDrawVerticesOp.cpp b/src/gpu/ops/GrDrawVerticesOp.cpp index 7420a5275a..fd49face0e 100644 --- a/src/gpu/ops/GrDrawVerticesOp.cpp +++ b/src/gpu/ops/GrDrawVerticesOp.cpp @@ -39,13 +39,19 @@ std::unique_ptr<GrDrawOp> GrDrawVerticesOp::Make( } 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::move(pos), std::move(col), - std::move(lc), - vertexCount, std::move(idx), indexCount, bounds); + vertices = SkVertices::MakeIndexed( + kIgnoredMode, std::unique_ptr<const SkPoint[]>((const SkPoint*)pos.release()), + std::unique_ptr<const SkColor[]>(col.release()), + std::unique_ptr<const SkPoint[]>(lc.release()), vertexCount, + std::unique_ptr<const uint16_t[]>(idx.release()), indexCount, bounds); } else { - vertices = SkVertices::Make(kIgnoredMode, std::move(pos), std::move(col), std::move(lc), - vertexCount, bounds); + vertices = SkVertices::Make(kIgnoredMode, std::unique_ptr<const SkPoint[]>(pos.release()), + std::unique_ptr<const SkColor[]>(col.release()), + std::unique_ptr<const SkPoint[]>(lc.release()), vertexCount, + bounds); } if (!vertices) { return nullptr; |