Commit b2022a76 by Nicolas Capens

Use gl::Object to reference count egl::Image.

Bug 26851951 Change-Id: I5b594bdd34e6fa1074d5439ee2c09f6731839dee Reviewed-on: https://swiftshader-review.googlesource.com/4534Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 3d7be4ea
......@@ -1132,7 +1132,7 @@ namespace egl
Image::~Image()
{
ASSERT(referenceCount == 0);
ASSERT(!shared);
}
void Image::addRef()
......@@ -1141,8 +1141,8 @@ namespace egl
{
return parentTexture->addRef();
}
int newCount = sw::atomicIncrement(&referenceCount);
LOGLOCK("%s image=%p referenceCount=%d", __FUNCTION__, this, newCount);
Object::addRef();
}
void Image::release()
......@@ -1152,20 +1152,14 @@ namespace egl
return parentTexture->release();
}
int newCount = sw::atomicDecrement(&referenceCount);
LOGLOCK("%s image=%p referenceCount=%d", __FUNCTION__, this, newCount);
if (newCount == 0)
{
ASSERT(!shared); // Should still hold a reference if eglDestroyImage hasn't been called
delete this;
}
Object::release();
}
void Image::unbind(const egl::Texture *parent)
{
if(parentTexture == parent)
{
parentTexture = 0;
parentTexture = nullptr;
}
release();
......
......@@ -36,7 +36,7 @@ static inline sw::Resource *getParentResource(egl::Texture *texture)
return texture ? texture->getResource() : nullptr;
}
class Image : public sw::Surface
class Image : public sw::Surface, public gl::Object
{
public:
Image(Texture *parentTexture, GLsizei width, GLsizei height, GLenum format, GLenum type)
......@@ -45,7 +45,7 @@ public:
parentTexture(parentTexture)
{
shared = false;
referenceCount = 1;
Object::addRef();
}
Image(Texture *parentTexture, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pitchP = 0)
......@@ -54,7 +54,7 @@ public:
parentTexture(parentTexture)
{
shared = false;
referenceCount = 1;
Object::addRef();
}
Image(GLsizei width, GLsizei height, sw::Format internalFormat, int multiSampleDepth, bool lockable, bool renderTarget)
......@@ -62,7 +62,7 @@ public:
width(width), height(height), format(0 /*GL_NONE*/), type(0 /*GL_NONE*/), internalFormat(internalFormat), depth(multiSampleDepth), parentTexture(nullptr)
{
shared = false;
referenceCount = 1;
Object::addRef();
}
GLsizei getWidth() const
......@@ -137,8 +137,8 @@ public:
void loadImageData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const UnpackInfo& unpackInfo, const void *input);
void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
virtual void addRef();
virtual void release();
void addRef() override;
void release() override;
virtual void unbind(const Texture *parent); // Break parent ownership and release
virtual void destroyShared() // Release a shared image
......@@ -160,8 +160,6 @@ protected:
egl::Texture *parentTexture;
volatile int referenceCount;
virtual ~Image();
void loadD24S8ImageData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, int inputPitch, int inputHeight, const void *input, void *buffer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment