Commit 1c7f08c3 by Jamie Madill Committed by Commit Bot

Inline RefCountObject::release.

Also don't return errors from the object release methods. Not returning errors reduces the amount of code generated. Also we shouldn't be exiting early from destructor type functions. Increases object binding performance. Bug: angleproject:2877 Change-Id: Ieb8120d885b946915e355419825e1f52f31d7b49 Reviewed-on: https://chromium-review.googlesource.com/c/1270218Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent f955bdac
......@@ -47,12 +47,11 @@ Buffer::~Buffer()
SafeDelete(mImpl);
}
Error Buffer::onDestroy(const Context *context)
void Buffer::onDestroy(const Context *context)
{
// In tests, mImpl might be null.
if (mImpl)
mImpl->destroy(context);
return NoError();
}
void Buffer::setLabel(const std::string &label)
......
......@@ -69,7 +69,7 @@ class Buffer final : public RefCountObject, public LabeledObject
public:
Buffer(rx::GLImplFactory *factory, GLuint id);
~Buffer() override;
Error onDestroy(const Context *context) override;
void onDestroy(const Context *context) override;
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
......
......@@ -593,7 +593,7 @@ egl::Error Context::onDestroy(const egl::Display *display)
{
if (zeroTexture.get() != nullptr)
{
ANGLE_TRY(zeroTexture->onDestroy(this));
zeroTexture->onDestroy(this);
zeroTexture.set(this, nullptr);
}
}
......
......@@ -71,9 +71,8 @@ Sync::Sync(rx::SyncImpl *impl, GLuint id)
{
}
Error Sync::onDestroy(const Context *context)
void Sync::onDestroy(const Context *context)
{
return NoError();
}
Sync::~Sync()
......
......@@ -54,7 +54,7 @@ class Sync final : public RefCountObject, public LabeledObject
Sync(rx::SyncImpl *impl, GLuint id);
~Sync() override;
Error onDestroy(const Context *context) override;
void onDestroy(const Context *context) override;
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
......
......@@ -162,7 +162,7 @@ Image::Image(rx::EGLImplFactory *factory,
mState.source->addImageSource(this);
}
Error Image::onDestroy(const Display *display)
void Image::onDestroy(const Display *display)
{
// All targets should hold a ref to the egl image and it should not be deleted until there are
// no siblings left.
......@@ -174,8 +174,6 @@ Error Image::onDestroy(const Display *display)
mState.source->removeImageSource(this);
mState.source = nullptr;
}
return NoError();
}
Image::~Image()
......
......@@ -92,7 +92,7 @@ class Image final : public RefCountObject, public LabeledObject
ImageSibling *buffer,
const AttributeMap &attribs);
Error onDestroy(const Display *display) override;
void onDestroy(const Display *display) override;
~Image() override;
void setLabel(EGLLabelKHR label) override;
......
......@@ -42,9 +42,8 @@ ProgramPipeline::~ProgramPipeline()
mProgramPipeline.release();
}
Error ProgramPipeline::onDestroy(const Context *context)
void ProgramPipeline::onDestroy(const Context *context)
{
return NoError();
}
void ProgramPipeline::setLabel(const std::string &label)
......
......@@ -48,7 +48,7 @@ class ProgramPipeline final : public RefCountObject, public LabeledObject
ProgramPipeline(rx::GLImplFactory *factory, GLuint handle);
~ProgramPipeline() override;
Error onDestroy(const Context *context) override;
void onDestroy(const Context *context) override;
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
......
......@@ -20,10 +20,10 @@ Query::~Query()
SafeDelete(mQuery);
}
Error Query::onDestroy(const Context *context)
void Query::onDestroy(const Context *context)
{
ASSERT(mQuery);
return mQuery->onDestroy(context);
ANGLE_SWALLOW_ERR(mQuery->onDestroy(context));
}
void Query::setLabel(const std::string &label)
......
......@@ -31,7 +31,7 @@ class Query final : public RefCountObject, public LabeledObject
public:
Query(rx::QueryImpl *impl, GLuint id);
~Query() override;
Error onDestroy(const Context *context) override;
void onDestroy(const Context *context) override;
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
......
......@@ -30,16 +30,16 @@ class RefCountObject : angle::NonCopyable
RefCountObject() : mRefCount(0) {}
virtual ErrorType onDestroy(const ContextType *context) { return ErrorType::NoError(); }
virtual void onDestroy(const ContextType *context) {}
void addRef() const { ++mRefCount; }
void release(const ContextType *context)
ANGLE_INLINE void release(const ContextType *context)
{
ASSERT(mRefCount > 0);
if (--mRefCount == 0)
{
ANGLE_SWALLOW_ERR(onDestroy(context));
onDestroy(context);
delete this;
}
}
......
......@@ -74,16 +74,14 @@ Renderbuffer::Renderbuffer(rx::GLImplFactory *implFactory, GLuint id)
{
}
Error Renderbuffer::onDestroy(const Context *context)
void Renderbuffer::onDestroy(const Context *context)
{
ANGLE_TRY(orphanImages(context));
ANGLE_SWALLOW_ERR(orphanImages(context));
if (mImplementation)
{
ANGLE_TRY(mImplementation->onDestroy(context));
ANGLE_SWALLOW_ERR(mImplementation->onDestroy(context));
}
return NoError();
}
Renderbuffer::~Renderbuffer()
......
......@@ -67,7 +67,7 @@ class Renderbuffer final : public RefCountObject, public egl::ImageSibling, publ
Renderbuffer(rx::GLImplFactory *implFactory, GLuint id);
~Renderbuffer() override;
Error onDestroy(const Context *context) override;
void onDestroy(const Context *context) override;
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
......
......@@ -25,9 +25,8 @@ Sampler::~Sampler()
SafeDelete(mImpl);
}
Error Sampler::onDestroy(const Context *context)
void Sampler::onDestroy(const Context *context)
{
return NoError();
}
void Sampler::setLabel(const std::string &label)
......
......@@ -30,7 +30,7 @@ class Sampler final : public RefCountObject, public LabeledObject, public angle:
Sampler(rx::GLImplFactory *factory, GLuint id);
~Sampler() override;
Error onDestroy(const Context *context) override;
void onDestroy(const Context *context) override;
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
......
......@@ -595,11 +595,11 @@ Texture::Texture(rx::GLImplFactory *factory, GLuint id, TextureType type)
mDirtyBits.set(DIRTY_BIT_IMPLEMENTATION);
}
Error Texture::onDestroy(const Context *context)
void Texture::onDestroy(const Context *context)
{
if (mBoundSurface)
{
ANGLE_TRY(mBoundSurface->releaseTexImage(context, EGL_BACK_BUFFER));
ANGLE_SWALLOW_ERR(mBoundSurface->releaseTexImage(context, EGL_BACK_BUFFER));
mBoundSurface = nullptr;
}
if (mBoundStream)
......@@ -608,13 +608,12 @@ Error Texture::onDestroy(const Context *context)
mBoundStream = nullptr;
}
ANGLE_TRY(orphanImages(context));
ANGLE_SWALLOW_ERR(orphanImages(context));
if (mTexture)
{
ANGLE_TRY(mTexture->onDestroy(context));
ANGLE_SWALLOW_ERR(mTexture->onDestroy(context));
}
return NoError();
}
Texture::~Texture()
......
......@@ -197,7 +197,7 @@ class Texture final : public RefCountObject,
Texture(rx::GLImplFactory *factory, GLuint id, TextureType type);
~Texture() override;
Error onDestroy(const Context *context) override;
void onDestroy(const Context *context) override;
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
......
......@@ -80,7 +80,7 @@ TransformFeedback::TransformFeedback(rx::GLImplFactory *implFactory, GLuint id,
ASSERT(mImplementation != nullptr);
}
Error TransformFeedback::onDestroy(const Context *context)
void TransformFeedback::onDestroy(const Context *context)
{
ASSERT(!context || !context->isCurrentTransformFeedback(this));
if (mState.mProgram)
......@@ -94,8 +94,6 @@ Error TransformFeedback::onDestroy(const Context *context)
{
mState.mIndexedBuffers[i].set(context, nullptr);
}
return NoError();
}
TransformFeedback::~TransformFeedback()
......
......@@ -58,7 +58,7 @@ class TransformFeedback final : public RefCountObject, public LabeledObject
public:
TransformFeedback(rx::GLImplFactory *implFactory, GLuint id, const Caps &caps);
~TransformFeedback() override;
Error onDestroy(const Context *context) override;
void onDestroy(const Context *context) override;
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
......
......@@ -407,7 +407,7 @@ void IncompleteTextureSet::onDestroy(const gl::Context *context)
{
if (incompleteTexture.get() != nullptr)
{
ANGLE_SWALLOW_ERR(incompleteTexture->onDestroy(context));
incompleteTexture->onDestroy(context);
incompleteTexture.set(context, nullptr);
}
}
......
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