aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrGeometryData.h
blob: a4e9fe6871165d09f41156b5891e5275948bb174 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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