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

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: fix param init order warning 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
« no previous file with comments | « include/gpu/GrGpuResourceRef.h ('k') | src/gpu/GrGpuResourceRef.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrAllocator.h
diff --git a/src/gpu/GrAllocator.h b/src/gpu/GrAllocator.h
index fd45e8ad68b310bf92593b531cce7f4f7e4110db..861c3cbe2cffc8cf7ce5271729e85dd07cbd286b 100644
--- a/src/gpu/GrAllocator.h
+++ b/src/gpu/GrAllocator.h
@@ -224,8 +224,10 @@ private:
typedef SkNoncopyable INHERITED;
};
-template <typename T>
-class GrTAllocator : SkNoncopyable {
+template <typename T> class GrTAllocator;
+template <typename T> void* operator new(size_t, GrTAllocator<T>*);
+
+template <typename T> class GrTAllocator : SkNoncopyable {
public:
virtual ~GrTAllocator() { this->reset(); };
@@ -360,6 +362,8 @@ protected:
}
private:
+ friend void* operator new<T>(size_t, GrTAllocator*);
+
GrAllocator fAllocator;
typedef SkNoncopyable INHERITED;
};
@@ -377,4 +381,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
« no previous file with comments | « include/gpu/GrGpuResourceRef.h ('k') | src/gpu/GrGpuResourceRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698