Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2061)

Unified Diff: src/core/SkAdvancedTypefaceMetrics.h

Issue 1780933003: Use std::unique_ptr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: once more, all together Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/private/SkUniquePtr.h ('k') | src/core/SkAdvancedTypefaceMetrics.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkAdvancedTypefaceMetrics.h
diff --git a/src/core/SkAdvancedTypefaceMetrics.h b/src/core/SkAdvancedTypefaceMetrics.h
index b2c9ac3142d0df2fe4995b0084af2f4a6dfdccb9..5a2180fade0364d2899bf35bbb428f71fe0259fd 100644
--- a/src/core/SkAdvancedTypefaceMetrics.h
+++ b/src/core/SkAdvancedTypefaceMetrics.h
@@ -16,6 +16,35 @@
#include "SkTDArray.h"
#include "SkTemplates.h"
+// Whatever std::unique_ptr Clank's using doesn't seem to work with AdvanceMetric's
+// style of forward-declaration. Probably just a bug in an old libc++ / libstdc++.
+// For now, hack around it with our own smart pointer. It'd be nice to clean up.
+template <typename T>
+class SkHackyAutoTDelete : SkNoncopyable {
+public:
+ explicit SkHackyAutoTDelete(T* ptr = nullptr) : fPtr(ptr) {}
+ ~SkHackyAutoTDelete() { delete fPtr; }
+
+ T* get() const { return fPtr; }
+ T* operator->() const { return fPtr; }
+
+ void reset(T* ptr) {
+ if (ptr != fPtr) {
+ delete fPtr;
+ fPtr = ptr;
+ }
+ }
+ void free() { this->reset(nullptr); }
+ T* detach() {
+ T* ptr = fPtr;
+ fPtr = nullptr;
+ return ptr;
+ }
+
+private:
+ T* fPtr;
+};
+
/** \class SkAdvancedTypefaceMetrics
The SkAdvancedTypefaceMetrics class is used by the PDF backend to correctly
@@ -97,7 +126,7 @@ public:
uint16_t fStartId;
uint16_t fEndId;
SkTDArray<Data> fAdvance;
- SkAutoTDelete<AdvanceMetric<Data> > fNext;
+ SkHackyAutoTDelete<AdvanceMetric<Data> > fNext;
};
struct VerticalMetric {
@@ -130,9 +159,9 @@ template <typename Data>
void resetRange(SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* range,
int startId);
-template <typename Data>
+template <typename Data, template<typename> class AutoTDelete>
SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* appendRange(
- SkAutoTDelete<SkAdvancedTypefaceMetrics::AdvanceMetric<Data> >* nextSlot,
+ AutoTDelete<SkAdvancedTypefaceMetrics::AdvanceMetric<Data> >* nextSlot,
int startId);
template <typename Data>
« no previous file with comments | « include/private/SkUniquePtr.h ('k') | src/core/SkAdvancedTypefaceMetrics.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698