diff options
Diffstat (limited to 'src/gpu/GrGeometryData.h')
-rw-r--r-- | src/gpu/GrGeometryData.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/gpu/GrGeometryData.h b/src/gpu/GrGeometryData.h new file mode 100644 index 0000000000..a4e9fe6871 --- /dev/null +++ b/src/gpu/GrGeometryData.h @@ -0,0 +1,42 @@ +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrGeometryData_DEFINED +#define GrGeometryData_DEFINED + +#include <new> +#include "SkTypes.h" + +/* + * A super lightweight base class for GeometryProcessor's to use to store draw data in a reorderable + * fashion. Its most important feature is a pool allocator. Its virtual, but only so subclasses + * will have their destructors called. + */ + +class GrGeometryData : SkNoncopyable { +public: + virtual ~GrGeometryData() {} + + /** + * Helper for down-casting to a GrGeometryData subclass + */ + template <typename T> const T& cast() const { return *static_cast<const T*>(this); } + + void* operator new(size_t size); + + void operator delete(void* target); + + void* operator new(size_t size, void* placement) { + return ::operator new(size, placement); + } + + void operator delete(void* target, void* placement) { + ::operator delete(target, placement); + } +}; + +#endif |