blob: a4e9fe6871165d09f41156b5891e5275948bb174 [file] [log] [blame]
joshualittc07379d2014-11-20 14:50:39 -08001/*
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
20class GrGeometryData : SkNoncopyable {
21public:
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