summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/libANGLE/RefCountObject.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/angle/src/libANGLE/RefCountObject.h')
-rw-r--r--src/3rdparty/angle/src/libANGLE/RefCountObject.h41
1 files changed, 35 insertions, 6 deletions
diff --git a/src/3rdparty/angle/src/libANGLE/RefCountObject.h b/src/3rdparty/angle/src/libANGLE/RefCountObject.h
index 48c0338c3f..86e6d788b5 100644
--- a/src/3rdparty/angle/src/libANGLE/RefCountObject.h
+++ b/src/3rdparty/angle/src/libANGLE/RefCountObject.h
@@ -21,14 +21,27 @@
class RefCountObject : angle::NonCopyable
{
public:
- explicit RefCountObject(GLuint id);
- virtual ~RefCountObject();
+ explicit RefCountObject(GLuint id) : mId(id), mRefCount(0) {}
- virtual void addRef() const;
- virtual void release() const;
+ void addRef() const { ++mRefCount; }
+
+ void release() const
+ {
+ ASSERT(mRefCount > 0);
+
+ if (--mRefCount == 0)
+ {
+ delete this;
+ }
+ }
GLuint id() const { return mId; }
+ size_t getRefCount() const { return mRefCount; }
+
+ protected:
+ virtual ~RefCountObject() { ASSERT(mRefCount == 0); }
+
private:
GLuint mId;
@@ -38,7 +51,7 @@ class RefCountObject : angle::NonCopyable
template <class ObjectType>
class BindingPointer
{
-public:
+ public:
BindingPointer()
: mObject(nullptr)
{
@@ -73,7 +86,13 @@ public:
ObjectType *operator->() const { return mObject; }
GLuint id() const { return (mObject != nullptr) ? mObject->id() : 0; }
- bool operator!() const { return (mObject == nullptr); }
+
+ bool operator==(const BindingPointer<ObjectType> &other) const
+ {
+ return mObject == other.mObject;
+ }
+
+ bool operator!=(const BindingPointer<ObjectType> &other) const { return !(*this == other); }
private:
ObjectType *mObject;
@@ -102,6 +121,16 @@ class OffsetBindingPointer : public BindingPointer<ObjectType>
GLintptr getOffset() const { return mOffset; }
GLsizeiptr getSize() const { return mSize; }
+ bool operator==(const OffsetBindingPointer<ObjectType> &other) const
+ {
+ return this->get() == other.get() && mOffset == other.mOffset && mSize == other.mSize;
+ }
+
+ bool operator!=(const OffsetBindingPointer<ObjectType> &other) const
+ {
+ return !(*this == other);
+ }
+
private:
GLintptr mOffset;
GLsizeiptr mSize;