joshualitt | c07379d | 2014-11-20 14:50:39 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrGeometryData_DEFINED |
| 9 | #define GrGeometryData_DEFINED |
| 10 | |
| 11 | #include <new> |
| 12 | #include "SkTypes.h" |
| 13 | |
| 14 | /* |
| 15 | * A super lightweight base class for GeometryProcessor's to use to store draw data in a reorderable |
| 16 | * fashion. Its most important feature is a pool allocator. Its virtual, but only so subclasses |
| 17 | * will have their destructors called. |
| 18 | */ |
| 19 | |
| 20 | class GrGeometryData : SkNoncopyable { |
| 21 | public: |
| 22 | virtual ~GrGeometryData() {} |
| 23 | |
| 24 | /** |
| 25 | * Helper for down-casting to a GrGeometryData subclass |
| 26 | */ |
| 27 | template <typename T> const T& cast() const { return *static_cast<const T*>(this); } |
| 28 | |
| 29 | void* operator new(size_t size); |
| 30 | |
| 31 | void operator delete(void* target); |
| 32 | |
| 33 | void* operator new(size_t size, void* placement) { |
| 34 | return ::operator new(size, placement); |
| 35 | } |
| 36 | |
| 37 | void operator delete(void* target, void* placement) { |
| 38 | ::operator delete(target, placement); |
| 39 | } |
| 40 | }; |
| 41 | |
| 42 | #endif |