michael@0: michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef GrTextureObj_DEFINED michael@0: #define GrTextureObj_DEFINED michael@0: michael@0: #include "GrFBBindableObj.h" michael@0: michael@0: class GrTextureUnitObj; michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: class GrTextureObj : public GrFBBindableObj { michael@0: GR_DEFINE_CREATOR(GrTextureObj); michael@0: michael@0: public: michael@0: GrTextureObj() michael@0: : GrFBBindableObj() { michael@0: } michael@0: michael@0: virtual ~GrTextureObj() { michael@0: GrAlwaysAssert(0 == fTextureUnitReferees.count()); michael@0: } michael@0: michael@0: void setBound(GrTextureUnitObj *referee) { michael@0: fTextureUnitReferees.append(1, &referee); michael@0: } michael@0: michael@0: void resetBound(GrTextureUnitObj *referee) { michael@0: int index = fTextureUnitReferees.find(referee); michael@0: GrAlwaysAssert(0 <= index); michael@0: fTextureUnitReferees.removeShuffle(index); michael@0: } michael@0: bool getBound(GrTextureUnitObj *referee) const { michael@0: int index = fTextureUnitReferees.find(referee); michael@0: return 0 <= index; michael@0: } michael@0: bool getBound() const { michael@0: return 0 != fTextureUnitReferees.count(); michael@0: } michael@0: michael@0: virtual void deleteAction() SK_OVERRIDE; michael@0: michael@0: protected: michael@0: michael@0: private: michael@0: // texture units that bind this texture (via "glBindTexture") michael@0: SkTDArray fTextureUnitReferees; michael@0: michael@0: typedef GrFBBindableObj INHERITED; michael@0: }; michael@0: michael@0: #endif // GrTextureObj_DEFINED