Work around GCC 4.6 issue with constructing unique_ptr<const T[]> from a T*.
authorBrian Salomon <bsalomon@google.com>
Tue, 31 Jan 2017 16:26:26 +0000 (11:26 -0500)
committerHal Canary <halcanary@google.com>
Tue, 31 Jan 2017 16:42:16 +0000 (16:42 +0000)
Change-Id: I74f309f56e5042ad58c7e959d5bc434de1446efa
Reviewed-on: https://skia-review.googlesource.com/7793
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>

src/utils/SkShadowTessellator.cpp

index 147ff53..fdbdf7f 100755 (executable)
@@ -25,9 +25,17 @@ public:
     int vertexCount() const { return fPositions.count(); }
     int indexCount() const { return fIndices.count(); }
 
-    UniqueArray<SkPoint> releasePositions() { return UniqueArray<SkPoint>(fPositions.release()); }
-    UniqueArray<SkColor> releaseColors() { return UniqueArray<SkColor>(fColors.release()); }
-    UniqueArray<uint16_t> releaseIndices() { return UniqueArray<uint16_t>(fIndices.release()); }
+    // The casts are needed to work around a, older GCC issue where the fact that the pointers are
+    // T* and not const T* causes calls to a deleted unique_ptr constructor.
+    UniqueArray<SkPoint> releasePositions() {
+        return UniqueArray<SkPoint>(static_cast<const SkPoint*>(fPositions.release()));
+    }
+    UniqueArray<SkColor> releaseColors() {
+        return UniqueArray<SkColor>(static_cast<const SkColor*>(fColors.release()));
+    }
+    UniqueArray<uint16_t> releaseIndices() {
+        return UniqueArray<uint16_t>(static_cast<const uint16_t*>(fIndices.release()));
+    }
 
 private:
     void handleLine(const SkPoint& p);
@@ -367,9 +375,17 @@ public:
     int vertexCount() const { return fPositions.count(); }
     int indexCount() const { return fIndices.count(); }
 
-    UniqueArray<SkPoint> releasePositions() { return UniqueArray<SkPoint>(fPositions.release()); }
-    UniqueArray<SkColor> releaseColors() { return UniqueArray<SkColor>(fColors.release()); }
-    UniqueArray<uint16_t> releaseIndices() { return UniqueArray<uint16_t>(fIndices.release()); }
+    // The casts are needed to work around an older GCC issue where the fact that the pointers are
+    // T* and not const T* causes calls to a deleted unique_ptr constructor.
+    UniqueArray<SkPoint> releasePositions() {
+        return UniqueArray<SkPoint>(static_cast<const SkPoint*>(fPositions.release()));
+    }
+    UniqueArray<SkColor> releaseColors() {
+        return UniqueArray<SkColor>(static_cast<const SkColor*>(fColors.release()));
+    }
+    UniqueArray<uint16_t> releaseIndices() {
+        return UniqueArray<uint16_t>(static_cast<const uint16_t*>(fIndices.release()));
+    }
 
 private:
     void computeClipBounds(const SkPath& path);