2016-03-31 01:56:19 +00:00
|
|
|
|
2012-04-05 14:40:53 +00:00
|
|
|
/*
|
|
|
|
* 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:
|
2012-08-23 18:09:54 +00:00
|
|
|
GrTextureObj()
|
2012-04-05 14:40:53 +00:00
|
|
|
: GrFBBindableObj() {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~GrTextureObj() {
|
|
|
|
GrAlwaysAssert(0 == fTextureUnitReferees.count());
|
|
|
|
}
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
void setBound(GrTextureUnitObj *referee) {
|
2012-04-05 14:40:53 +00:00
|
|
|
fTextureUnitReferees.append(1, &referee);
|
|
|
|
}
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
void resetBound(GrTextureUnitObj *referee) {
|
2012-04-05 14:40:53 +00:00
|
|
|
int index = fTextureUnitReferees.find(referee);
|
|
|
|
GrAlwaysAssert(0 <= index);
|
|
|
|
fTextureUnitReferees.removeShuffle(index);
|
|
|
|
}
|
2012-08-23 18:09:54 +00:00
|
|
|
bool getBound(GrTextureUnitObj *referee) const {
|
2012-04-05 14:40:53 +00:00
|
|
|
int index = fTextureUnitReferees.find(referee);
|
|
|
|
return 0 <= index;
|
|
|
|
}
|
2012-08-23 18:09:54 +00:00
|
|
|
bool getBound() const {
|
2012-04-05 14:40:53 +00:00
|
|
|
return 0 != fTextureUnitReferees.count();
|
|
|
|
}
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void deleteAction() override;
|
2012-04-05 14:40:53 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
private:
|
|
|
|
// texture units that bind this texture (via "glBindTexture")
|
2012-08-23 18:09:54 +00:00
|
|
|
SkTDArray<GrTextureUnitObj *> fTextureUnitReferees;
|
2012-04-05 14:40:53 +00:00
|
|
|
|
|
|
|
typedef GrFBBindableObj INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GrTextureObj_DEFINED
|