Refactor GL objects into named and unnamed ones.
Bug 20045861
Change-Id: Ib6a6625d3eb876a1444ae4dab17c6e25246fbc43
Reviewed-on: https://swiftshader-review.googlesource.com/2794
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/common/Object.cpp b/src/OpenGL/common/Object.cpp
index d9a868a..c8118b3 100644
--- a/src/OpenGL/common/Object.cpp
+++ b/src/OpenGL/common/Object.cpp
@@ -20,7 +20,7 @@
namespace gl
{
-Object::Object(GLuint name) : name(name)
+Object::Object()
{
referenceCount = 0;
}
@@ -50,4 +50,12 @@
}
}
+NamedObject::NamedObject(GLuint name) : name(name)
+{
+}
+
+NamedObject::~NamedObject()
+{
+}
+
}
diff --git a/src/OpenGL/common/Object.hpp b/src/OpenGL/common/Object.hpp
index b1921d7..8c8ee7c 100644
--- a/src/OpenGL/common/Object.hpp
+++ b/src/OpenGL/common/Object.hpp
@@ -26,18 +26,25 @@
class Object
{
public:
- explicit Object(GLuint name);
+ Object();
virtual ~Object();
virtual void addRef();
virtual void release();
-
- const GLuint name;
private:
volatile int referenceCount;
};
+class NamedObject : public Object
+{
+public:
+ explicit NamedObject(GLuint name);
+ virtual ~NamedObject();
+
+ const GLuint name;
+};
+
template<class ObjectType>
class BindingPointer
{
diff --git a/src/OpenGL/libEGL/Texture.hpp b/src/OpenGL/libEGL/Texture.hpp
index 164c480..958a595 100644
--- a/src/OpenGL/libEGL/Texture.hpp
+++ b/src/OpenGL/libEGL/Texture.hpp
@@ -5,10 +5,10 @@
namespace egl
{
-class Texture : public gl::Object
+class Texture : public gl::NamedObject
{
public:
- Texture(GLuint name) : Object(name) {};
+ Texture(GLuint name) : NamedObject(name) {};
virtual void releaseTexImage() = 0;
};
}
diff --git a/src/OpenGL/libGL/Buffer.cpp b/src/OpenGL/libGL/Buffer.cpp
index 7c7b3f1..f4d7a52 100644
--- a/src/OpenGL/libGL/Buffer.cpp
+++ b/src/OpenGL/libGL/Buffer.cpp
@@ -21,7 +21,7 @@
namespace gl
{
-Buffer::Buffer(GLuint name) : Object(name)
+Buffer::Buffer(GLuint name) : NamedObject(name)
{
mContents = 0;
mSize = 0;
diff --git a/src/OpenGL/libGL/Buffer.h b/src/OpenGL/libGL/Buffer.h
index 6e6a1ee..dcccc3d 100644
--- a/src/OpenGL/libGL/Buffer.h
+++ b/src/OpenGL/libGL/Buffer.h
@@ -29,7 +29,7 @@
namespace gl
{
-class Buffer : public Object
+class Buffer : public NamedObject
{
public:
explicit Buffer(GLuint name);
diff --git a/src/OpenGL/libGL/Query.cpp b/src/OpenGL/libGL/Query.cpp
index be97611..9ef0790 100644
--- a/src/OpenGL/libGL/Query.cpp
+++ b/src/OpenGL/libGL/Query.cpp
@@ -19,7 +19,7 @@
namespace gl
{
-Query::Query(GLuint name, GLenum type) : Object(name)
+Query::Query(GLuint name, GLenum type) : NamedObject(name)
{
mQuery = NULL;
mStatus = GL_FALSE;
diff --git a/src/OpenGL/libGL/Query.h b/src/OpenGL/libGL/Query.h
index 6efd4fd..138e488 100644
--- a/src/OpenGL/libGL/Query.h
+++ b/src/OpenGL/libGL/Query.h
@@ -26,7 +26,7 @@
namespace gl
{
-class Query : public Object
+class Query : public NamedObject
{
public:
Query(GLuint name, GLenum type);
diff --git a/src/OpenGL/libGL/Renderbuffer.cpp b/src/OpenGL/libGL/Renderbuffer.cpp
index db49371..95887b5 100644
--- a/src/OpenGL/libGL/Renderbuffer.cpp
+++ b/src/OpenGL/libGL/Renderbuffer.cpp
@@ -180,7 +180,7 @@
////// Renderbuffer Implementation //////
-Renderbuffer::Renderbuffer(GLuint name, RenderbufferInterface *instance) : Object(name)
+Renderbuffer::Renderbuffer(GLuint name, RenderbufferInterface *instance) : NamedObject(name)
{
ASSERT(instance != NULL);
mInstance = instance;
diff --git a/src/OpenGL/libGL/Renderbuffer.h b/src/OpenGL/libGL/Renderbuffer.h
index 62b9e0a..50b7afb 100644
--- a/src/OpenGL/libGL/Renderbuffer.h
+++ b/src/OpenGL/libGL/Renderbuffer.h
@@ -134,7 +134,7 @@
// Renderbuffer implements the GL renderbuffer object.
// It's only a proxy for a RenderbufferInterface instance; the internal object
// can change whenever glRenderbufferStorage is called.
-class Renderbuffer : public Object
+class Renderbuffer : public NamedObject
{
public:
Renderbuffer(GLuint name, RenderbufferInterface *storage);
diff --git a/src/OpenGL/libGL/Texture.cpp b/src/OpenGL/libGL/Texture.cpp
index 137b39f..74c1daa 100644
--- a/src/OpenGL/libGL/Texture.cpp
+++ b/src/OpenGL/libGL/Texture.cpp
@@ -27,7 +27,7 @@
namespace gl
{
-Texture::Texture(GLuint name) : Object(name)
+Texture::Texture(GLuint name) : NamedObject(name)
{
mMinFilter = GL_NEAREST_MIPMAP_LINEAR;
mMagFilter = GL_LINEAR;
diff --git a/src/OpenGL/libGL/Texture.h b/src/OpenGL/libGL/Texture.h
index 82327f2..2a524b5 100644
--- a/src/OpenGL/libGL/Texture.h
+++ b/src/OpenGL/libGL/Texture.h
@@ -44,7 +44,7 @@
IMPLEMENTATION_MAX_SAMPLES = 4
};
-class Texture : public Object
+class Texture : public NamedObject
{
public:
explicit Texture(GLuint name);
diff --git a/src/OpenGL/libGLES_CM/Buffer.cpp b/src/OpenGL/libGLES_CM/Buffer.cpp
index 15b6978..7377d03 100644
--- a/src/OpenGL/libGLES_CM/Buffer.cpp
+++ b/src/OpenGL/libGLES_CM/Buffer.cpp
@@ -22,7 +22,7 @@
namespace es1
{
-Buffer::Buffer(GLuint name) : Object(name)
+Buffer::Buffer(GLuint name) : NamedObject(name)
{
mContents = 0;
mSize = 0;
diff --git a/src/OpenGL/libGLES_CM/Buffer.h b/src/OpenGL/libGLES_CM/Buffer.h
index b0dfce8..e43ab87 100644
--- a/src/OpenGL/libGLES_CM/Buffer.h
+++ b/src/OpenGL/libGLES_CM/Buffer.h
@@ -27,7 +27,7 @@
namespace es1
{
-class Buffer : public gl::Object
+class Buffer : public gl::NamedObject
{
public:
explicit Buffer(GLuint name);
diff --git a/src/OpenGL/libGLES_CM/Renderbuffer.cpp b/src/OpenGL/libGLES_CM/Renderbuffer.cpp
index 070a7a6..44a0b26 100644
--- a/src/OpenGL/libGLES_CM/Renderbuffer.cpp
+++ b/src/OpenGL/libGLES_CM/Renderbuffer.cpp
@@ -136,7 +136,7 @@
////// Renderbuffer Implementation //////
-Renderbuffer::Renderbuffer(GLuint name, RenderbufferInterface *instance) : Object(name)
+Renderbuffer::Renderbuffer(GLuint name, RenderbufferInterface *instance) : NamedObject(name)
{
ASSERT(instance != NULL);
mInstance = instance;
diff --git a/src/OpenGL/libGLES_CM/Renderbuffer.h b/src/OpenGL/libGLES_CM/Renderbuffer.h
index eb65708..31f12ee 100644
--- a/src/OpenGL/libGLES_CM/Renderbuffer.h
+++ b/src/OpenGL/libGLES_CM/Renderbuffer.h
@@ -113,7 +113,7 @@
// Renderbuffer implements the GL renderbuffer object.
// It's only a proxy for a RenderbufferInterface instance; the internal object
// can change whenever glRenderbufferStorage is called.
-class Renderbuffer : public gl::Object
+class Renderbuffer : public gl::NamedObject
{
public:
Renderbuffer(GLuint name, RenderbufferInterface *storage);
diff --git a/src/OpenGL/libGLESv2/Buffer.cpp b/src/OpenGL/libGLESv2/Buffer.cpp
index b162a5f..42a1eea 100644
--- a/src/OpenGL/libGLESv2/Buffer.cpp
+++ b/src/OpenGL/libGLESv2/Buffer.cpp
@@ -22,7 +22,7 @@
namespace es2
{
-Buffer::Buffer(GLuint name) : Object(name)
+Buffer::Buffer(GLuint name) : NamedObject(name)
{
mContents = 0;
mSize = 0;
diff --git a/src/OpenGL/libGLESv2/Buffer.h b/src/OpenGL/libGLESv2/Buffer.h
index 279227e..10f5423 100644
--- a/src/OpenGL/libGLESv2/Buffer.h
+++ b/src/OpenGL/libGLESv2/Buffer.h
@@ -27,7 +27,7 @@
namespace es2
{
-class Buffer : public gl::Object
+class Buffer : public gl::NamedObject
{
public:
explicit Buffer(GLuint name);
diff --git a/src/OpenGL/libGLESv2/Query.cpp b/src/OpenGL/libGLESv2/Query.cpp
index 4cc6b81..52e23ac 100644
--- a/src/OpenGL/libGLESv2/Query.cpp
+++ b/src/OpenGL/libGLESv2/Query.cpp
@@ -19,7 +19,7 @@
namespace es2
{
-Query::Query(GLuint name, GLenum type) : Object(name)
+Query::Query(GLuint name, GLenum type) : NamedObject(name)
{
mQuery = NULL;
mStatus = GL_FALSE;
diff --git a/src/OpenGL/libGLESv2/Query.h b/src/OpenGL/libGLESv2/Query.h
index 0e5ead8..2f99181 100644
--- a/src/OpenGL/libGLESv2/Query.h
+++ b/src/OpenGL/libGLESv2/Query.h
@@ -23,7 +23,7 @@
namespace es2
{
-class Query : public gl::Object
+class Query : public gl::NamedObject
{
public:
Query(GLuint name, GLenum type);
diff --git a/src/OpenGL/libGLESv2/Renderbuffer.cpp b/src/OpenGL/libGLESv2/Renderbuffer.cpp
index b35405d..38f4189 100644
--- a/src/OpenGL/libGLESv2/Renderbuffer.cpp
+++ b/src/OpenGL/libGLESv2/Renderbuffer.cpp
@@ -272,7 +272,7 @@
////// Renderbuffer Implementation //////
-Renderbuffer::Renderbuffer(GLuint name, RenderbufferInterface *instance) : Object(name)
+Renderbuffer::Renderbuffer(GLuint name, RenderbufferInterface *instance) : NamedObject(name)
{
ASSERT(instance != NULL);
mInstance = instance;
diff --git a/src/OpenGL/libGLESv2/Renderbuffer.h b/src/OpenGL/libGLESv2/Renderbuffer.h
index cfacbd5..4ffae7c 100644
--- a/src/OpenGL/libGLESv2/Renderbuffer.h
+++ b/src/OpenGL/libGLESv2/Renderbuffer.h
@@ -164,7 +164,7 @@
// Renderbuffer implements the GL renderbuffer object.
// It's only a proxy for a RenderbufferInterface instance; the internal object
// can change whenever glRenderbufferStorage is called.
-class Renderbuffer : public gl::Object
+class Renderbuffer : public gl::NamedObject
{
public:
Renderbuffer(GLuint name, RenderbufferInterface *storage);
diff --git a/src/OpenGL/libGLESv2/Sampler.h b/src/OpenGL/libGLESv2/Sampler.h
index e0b9502..476ad5a 100644
--- a/src/OpenGL/libGLESv2/Sampler.h
+++ b/src/OpenGL/libGLESv2/Sampler.h
@@ -23,10 +23,10 @@
namespace es2
{
-class Sampler : public gl::Object
+class Sampler : public gl::NamedObject
{
public:
- Sampler(GLuint name) : Object(name)
+ Sampler(GLuint name) : NamedObject(name)
{
mMinFilter = GL_NEAREST_MIPMAP_LINEAR;
mMagFilter = GL_LINEAR;
diff --git a/src/OpenGL/libGLESv2/TransformFeedback.cpp b/src/OpenGL/libGLESv2/TransformFeedback.cpp
index 8c403dc..282bd74 100644
--- a/src/OpenGL/libGLESv2/TransformFeedback.cpp
+++ b/src/OpenGL/libGLESv2/TransformFeedback.cpp
@@ -18,7 +18,7 @@
namespace es2
{
-TransformFeedback::TransformFeedback(GLuint name) : Object(name), mActive(false), mPaused(false)
+TransformFeedback::TransformFeedback(GLuint name) : NamedObject(name), mActive(false), mPaused(false)
{
mGenericBuffer = NULL;
}
diff --git a/src/OpenGL/libGLESv2/TransformFeedback.h b/src/OpenGL/libGLESv2/TransformFeedback.h
index 52a1bfe..e46d748 100644
--- a/src/OpenGL/libGLESv2/TransformFeedback.h
+++ b/src/OpenGL/libGLESv2/TransformFeedback.h
@@ -24,7 +24,7 @@
{
class Buffer;
-class TransformFeedback : public gl::Object
+class TransformFeedback : public gl::NamedObject
{
public:
// FIXME: Change this when implementing transform feedback