Make FramebufferAttachmentObject not refcountable
Instead the refcount is done via callbacks. This allows Surface to
ignore this refcounting which will be useful in a follow-up CL.
BUG=angleproject:891
Change-Id: I39b028476e0e3ab1837c033e1121ea21e54d7970
Reviewed-on: https://chromium-review.googlesource.com/291651
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp
index fda3e8f..05b9d55 100644
--- a/src/libANGLE/Context.cpp
+++ b/src/libANGLE/Context.cpp
@@ -36,9 +36,15 @@
namespace gl
{
-Context::Context(const egl::Config *config, int clientVersion, const Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess)
+Context::Context(const egl::Config *config,
+ int clientVersion,
+ const Context *shareContext,
+ rx::Renderer *renderer,
+ bool notifyResets,
+ bool robustAccess)
: mRenderer(renderer),
mConfig(config),
+ mCurrentSurface(nullptr),
mData(clientVersion, mState, mCaps, mTextureCaps, mExtensions, nullptr)
{
ASSERT(robustAccess == false); // Unimplemented
@@ -163,6 +169,11 @@
}
mZeroTextures.clear();
+ if (mCurrentSurface != nullptr)
+ {
+ releaseSurface();
+ }
+
if (mResourceManager)
{
mResourceManager->release();
@@ -189,6 +200,15 @@
// TODO(jmadill): Rework this when we support ContextImpl
mState.setAllDirtyBits();
+ if (mCurrentSurface)
+ {
+ releaseSurface();
+ }
+
+ ASSERT(mCurrentSurface == nullptr);
+ mCurrentSurface = surface;
+ surface->setIsCurrent(true);
+
// Update default framebuffer
Framebuffer *defaultFBO = mFramebufferMap[0];
@@ -230,9 +250,16 @@
void Context::releaseSurface()
{
Framebuffer *defaultFBO = mFramebufferMap[0];
- defaultFBO->resetAttachment(GL_BACK);
- defaultFBO->resetAttachment(GL_DEPTH);
- defaultFBO->resetAttachment(GL_STENCIL);
+ if (defaultFBO)
+ {
+ defaultFBO->resetAttachment(GL_BACK);
+ defaultFBO->resetAttachment(GL_DEPTH);
+ defaultFBO->resetAttachment(GL_STENCIL);
+ }
+
+ ASSERT(mCurrentSurface != nullptr);
+ mCurrentSurface->setIsCurrent(false);
+ mCurrentSurface = nullptr;
}
// NOTE: this function should not assume that this context is current!