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

Unified Diff: src/gpu/GrAllocator.h

Issue 581123002: Make GrIODB keep pending IO refs on all resources it records into its cmd stream. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: minor Created 6 years, 3 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
Index: src/gpu/GrAllocator.h
diff --git a/src/gpu/GrAllocator.h b/src/gpu/GrAllocator.h
index fd45e8ad68b310bf92593b531cce7f4f7e4110db..b56b85c7768779cf415081fe8759ae94dd43cfce 100644
--- a/src/gpu/GrAllocator.h
+++ b/src/gpu/GrAllocator.h
@@ -224,8 +224,7 @@ private:
typedef SkNoncopyable INHERITED;
};
-template <typename T>
-class GrTAllocator : SkNoncopyable {
+template <typename T> class GrTAllocator : SkNoncopyable {
public:
virtual ~GrTAllocator() { this->reset(); };
@@ -360,6 +359,8 @@ protected:
}
private:
+ friend void* operator new<T>(size_t, GrTAllocator*);
+
GrAllocator fAllocator;
typedef SkNoncopyable INHERITED;
};
@@ -377,4 +378,18 @@ private:
SkAlignedSTStorage<N, T> fStorage;
};
+template <typename T> void* operator new(size_t size, GrTAllocator<T>* allocator) {
+ return allocator->fAllocator.push_back();
+}
+
+// Skia doesn't use C++ exceptions but it may be compiled with them enabled. Having an op delete
+// to match the op new silences warnings about missing op delete when a constructor throws an
+// exception.
+template <typename T> void operator delete(void*, GrTAllocator<T>*) {
+ SK_CRASH();
+}
+
+#define GrNEW_APPEND_TO_ALLOCATOR(allocator_ptr, type_name, args) \
+ new (allocator_ptr) type_name args
+
#endif

Powered by Google App Engine
This is Rietveld 408576698