aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/gpu/gl/debug/GrTextureObj.h
blob: 5532723969ac2133fa1179ae6f4620fe2ffecdaa (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GrTextureObj_DEFINED
#define GrTextureObj_DEFINED

#include "GrFBBindableObj.h"

class GrTextureUnitObj;

////////////////////////////////////////////////////////////////////////////////
class GrTextureObj : public GrFBBindableObj {
    GR_DEFINE_CREATOR(GrTextureObj)

public:
    GrTextureObj()
        : GrFBBindableObj() {
    }

    ~GrTextureObj() override {
        GrAlwaysAssert(0 == fTextureUnitReferees.count());
    }

    void setBound(GrTextureUnitObj *referee) {
        fTextureUnitReferees.append(1, &referee);
    }

    void resetBound(GrTextureUnitObj *referee) {
        int index = fTextureUnitReferees.find(referee);
        GrAlwaysAssert(0 <= index);
        fTextureUnitReferees.removeShuffle(index);
    }
    bool getBound(GrTextureUnitObj *referee) const {
        int index = fTextureUnitReferees.find(referee);
        return 0 <= index;
    }
    bool getBound() const {
        return 0 != fTextureUnitReferees.count();
    }

    void deleteAction() override;

protected:

private:
    // texture units that bind this texture (via "glBindTexture")
    SkTDArray<GrTextureUnitObj *> fTextureUnitReferees;

    typedef GrFBBindableObj INHERITED;
};

#endif // GrTextureObj_DEFINED