blob: 7673cd118e40df45919fc5444de96acdd861944b [file] [log] [blame]
robertphillips@google.comdd743fe2012-04-05 14:40:53 +00001
2/*
3 * Copyright 2012 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9#ifndef GrTextureObj_DEFINED
10#define GrTextureObj_DEFINED
11
12#include "GrFBBindableObj.h"
13
14class GrTextureUnitObj;
15
16////////////////////////////////////////////////////////////////////////////////
17class GrTextureObj : public GrFBBindableObj {
18 GR_DEFINE_CREATOR(GrTextureObj);
19
20public:
rmistry@google.comfbfcd562012-08-23 18:09:54 +000021 GrTextureObj()
robertphillips@google.comdd743fe2012-04-05 14:40:53 +000022 : GrFBBindableObj() {
23 }
24
25 virtual ~GrTextureObj() {
26 GrAlwaysAssert(0 == fTextureUnitReferees.count());
27 }
28
rmistry@google.comfbfcd562012-08-23 18:09:54 +000029 void setBound(GrTextureUnitObj *referee) {
robertphillips@google.comdd743fe2012-04-05 14:40:53 +000030 fTextureUnitReferees.append(1, &referee);
31 }
32
rmistry@google.comfbfcd562012-08-23 18:09:54 +000033 void resetBound(GrTextureUnitObj *referee) {
robertphillips@google.comdd743fe2012-04-05 14:40:53 +000034 int index = fTextureUnitReferees.find(referee);
35 GrAlwaysAssert(0 <= index);
36 fTextureUnitReferees.removeShuffle(index);
37 }
rmistry@google.comfbfcd562012-08-23 18:09:54 +000038 bool getBound(GrTextureUnitObj *referee) const {
robertphillips@google.comdd743fe2012-04-05 14:40:53 +000039 int index = fTextureUnitReferees.find(referee);
40 return 0 <= index;
41 }
rmistry@google.comfbfcd562012-08-23 18:09:54 +000042 bool getBound() const {
robertphillips@google.comdd743fe2012-04-05 14:40:53 +000043 return 0 != fTextureUnitReferees.count();
44 }
45
robertphillips@google.com0dd84a32012-04-16 16:24:35 +000046 virtual void deleteAction() SK_OVERRIDE;
robertphillips@google.comdd743fe2012-04-05 14:40:53 +000047
48protected:
49
50private:
51 // texture units that bind this texture (via "glBindTexture")
rmistry@google.comfbfcd562012-08-23 18:09:54 +000052 SkTDArray<GrTextureUnitObj *> fTextureUnitReferees;
robertphillips@google.comdd743fe2012-04-05 14:40:53 +000053
54 typedef GrFBBindableObj INHERITED;
55};
56
57#endif // GrTextureObj_DEFINED