diff options
author | bsalomon <bsalomon@google.com> | 2014-09-19 11:10:40 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-19 11:10:40 -0700 |
commit | b3e3a955b6628acc540ef14854b57abb089e62df (patch) | |
tree | 056b3b34e445396cee310ce15cac25999a2ad4e1 /src/gpu/GrAllocator.h | |
parent | 87e2437fe574a5ed76caa225c4ff6464641ef64f (diff) |
Make GrIODB keep pending IO refs on all resources it records into its cmd stream.
BUG=skia:2889
R=robertphillips@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/581123002
Diffstat (limited to 'src/gpu/GrAllocator.h')
-rw-r--r-- | src/gpu/GrAllocator.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/gpu/GrAllocator.h b/src/gpu/GrAllocator.h index fd45e8ad68..861c3cbe2c 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 |