Commit 0f4d72e6 by Geoff Lang Committed by Commit Bot

Add makeCurrent and unMakeCurrent to SurfaceImpl.

SurfaceGL had these methods already so they are just moving up the inheritance hierarchy. This ends up simplifying some state tracking we had in our surface implementations. BUG=angleproject:2464 Change-Id: I480588ca8470d9ef507f95e0c0297fe126b3abfb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1595434Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent e755a537
...@@ -8198,7 +8198,7 @@ egl::Error Context::setDefaultFramebuffer(egl::Surface *surface) ...@@ -8198,7 +8198,7 @@ egl::Error Context::setDefaultFramebuffer(egl::Surface *surface)
Framebuffer *newDefault = nullptr; Framebuffer *newDefault = nullptr;
if (surface != nullptr) if (surface != nullptr)
{ {
ANGLE_TRY(surface->setIsCurrent(this, true)); ANGLE_TRY(surface->makeCurrent(this));
mCurrentSurface = surface; mCurrentSurface = surface;
newDefault = surface->createDefaultFramebuffer(this); newDefault = surface->createDefaultFramebuffer(this);
} }
...@@ -8254,7 +8254,7 @@ egl::Error Context::unsetDefaultFramebuffer() ...@@ -8254,7 +8254,7 @@ egl::Error Context::unsetDefaultFramebuffer()
mCurrentSurface = nullptr; mCurrentSurface = nullptr;
if (surface) if (surface)
{ {
ANGLE_TRY(surface->setIsCurrent(this, false)); ANGLE_TRY(surface->unMakeCurrent(this));
} }
return egl::NoError(); return egl::NoError();
......
...@@ -177,14 +177,17 @@ Error Surface::initialize(const Display *display) ...@@ -177,14 +177,17 @@ Error Surface::initialize(const Display *display)
return NoError(); return NoError();
} }
Error Surface::setIsCurrent(const gl::Context *context, bool isCurrent) Error Surface::makeCurrent(const gl::Context *context)
{ {
if (isCurrent) ANGLE_TRY(mImplementation->makeCurrent(context));
{
mRefCount++;
return NoError();
}
mRefCount++;
return NoError();
}
Error Surface::unMakeCurrent(const gl::Context *context)
{
ANGLE_TRY(mImplementation->unMakeCurrent(context));
return releaseRef(context->getDisplay()); return releaseRef(context->getDisplay());
} }
......
...@@ -68,6 +68,8 @@ class Surface : public LabeledObject, public gl::FramebufferAttachmentObject ...@@ -68,6 +68,8 @@ class Surface : public LabeledObject, public gl::FramebufferAttachmentObject
EGLint getType() const; EGLint getType() const;
Error initialize(const Display *display); Error initialize(const Display *display);
Error makeCurrent(const gl::Context *context);
Error unMakeCurrent(const gl::Context *context);
Error swap(const gl::Context *context); Error swap(const gl::Context *context);
Error swapWithDamage(const gl::Context *context, EGLint *rects, EGLint n_rects); Error swapWithDamage(const gl::Context *context, EGLint *rects, EGLint n_rects);
Error postSubBuffer(const gl::Context *context, Error postSubBuffer(const gl::Context *context,
...@@ -85,7 +87,6 @@ class Surface : public LabeledObject, public gl::FramebufferAttachmentObject ...@@ -85,7 +87,6 @@ class Surface : public LabeledObject, public gl::FramebufferAttachmentObject
EGLint isPostSubBufferSupported() const; EGLint isPostSubBufferSupported() const;
void setSwapInterval(EGLint interval); void setSwapInterval(EGLint interval);
Error setIsCurrent(const gl::Context *context, bool isCurrent);
Error onDestroy(const Display *display); Error onDestroy(const Display *display);
void setMipmapLevel(EGLint level); void setMipmapLevel(EGLint level);
......
...@@ -15,6 +15,16 @@ SurfaceImpl::SurfaceImpl(const egl::SurfaceState &state) : mState(state) {} ...@@ -15,6 +15,16 @@ SurfaceImpl::SurfaceImpl(const egl::SurfaceState &state) : mState(state) {}
SurfaceImpl::~SurfaceImpl() {} SurfaceImpl::~SurfaceImpl() {}
egl::Error SurfaceImpl::makeCurrent(const gl::Context *context)
{
return egl::NoError();
}
egl::Error SurfaceImpl::unMakeCurrent(const gl::Context *context)
{
return egl::NoError();
}
egl::Error SurfaceImpl::swapWithDamage(const gl::Context *context, EGLint *rects, EGLint n_rects) egl::Error SurfaceImpl::swapWithDamage(const gl::Context *context, EGLint *rects, EGLint n_rects)
{ {
UNREACHABLE(); UNREACHABLE();
......
...@@ -53,6 +53,8 @@ class SurfaceImpl : public FramebufferAttachmentObjectImpl ...@@ -53,6 +53,8 @@ class SurfaceImpl : public FramebufferAttachmentObjectImpl
virtual egl::Error initialize(const egl::Display *display) = 0; virtual egl::Error initialize(const egl::Display *display) = 0;
virtual FramebufferImpl *createDefaultFramebuffer(const gl::Context *context, virtual FramebufferImpl *createDefaultFramebuffer(const gl::Context *context,
const gl::FramebufferState &state) = 0; const gl::FramebufferState &state) = 0;
virtual egl::Error makeCurrent(const gl::Context *context);
virtual egl::Error unMakeCurrent(const gl::Context *context);
virtual egl::Error swap(const gl::Context *context) = 0; virtual egl::Error swap(const gl::Context *context) = 0;
virtual egl::Error swapWithDamage(const gl::Context *context, EGLint *rects, EGLint n_rects); virtual egl::Error swapWithDamage(const gl::Context *context, EGLint *rects, EGLint n_rects);
virtual egl::Error postSubBuffer(const gl::Context *context, virtual egl::Error postSubBuffer(const gl::Context *context,
......
...@@ -22,9 +22,7 @@ ...@@ -22,9 +22,7 @@
namespace rx namespace rx
{ {
DisplayGL::DisplayGL(const egl::DisplayState &state) DisplayGL::DisplayGL(const egl::DisplayState &state) : DisplayImpl(state) {}
: DisplayImpl(state), mCurrentDrawSurface(nullptr)
{}
DisplayGL::~DisplayGL() {} DisplayGL::~DisplayGL() {}
...@@ -56,14 +54,6 @@ egl::Error DisplayGL::makeCurrent(egl::Surface *drawSurface, ...@@ -56,14 +54,6 @@ egl::Error DisplayGL::makeCurrent(egl::Surface *drawSurface,
egl::Surface *readSurface, egl::Surface *readSurface,
gl::Context *context) gl::Context *context)
{ {
// Notify the previous surface (if it still exists) that it is no longer current
if (mCurrentDrawSurface &&
mState.surfaceSet.find(mCurrentDrawSurface) != mState.surfaceSet.end())
{
ANGLE_TRY(GetImplAs<SurfaceGL>(mCurrentDrawSurface)->unMakeCurrent());
}
mCurrentDrawSurface = nullptr;
if (!context) if (!context)
{ {
return egl::NoError(); return egl::NoError();
...@@ -73,17 +63,12 @@ egl::Error DisplayGL::makeCurrent(egl::Surface *drawSurface, ...@@ -73,17 +63,12 @@ egl::Error DisplayGL::makeCurrent(egl::Surface *drawSurface,
ContextGL *glContext = GetImplAs<ContextGL>(context); ContextGL *glContext = GetImplAs<ContextGL>(context);
glContext->getStateManager()->pauseTransformFeedback(); glContext->getStateManager()->pauseTransformFeedback();
if (drawSurface != nullptr) if (drawSurface == nullptr)
{
SurfaceGL *glDrawSurface = GetImplAs<SurfaceGL>(drawSurface);
ANGLE_TRY(glDrawSurface->makeCurrent(context));
mCurrentDrawSurface = drawSurface;
return egl::NoError();
}
else
{ {
return makeCurrentSurfaceless(context); ANGLE_TRY(makeCurrentSurfaceless(context));
} }
return egl::NoError();
} }
void DisplayGL::generateExtensions(egl::DisplayExtensions *outExtensions) const void DisplayGL::generateExtensions(egl::DisplayExtensions *outExtensions) const
......
...@@ -48,8 +48,6 @@ class DisplayGL : public DisplayImpl ...@@ -48,8 +48,6 @@ class DisplayGL : public DisplayImpl
private: private:
virtual egl::Error makeCurrentSurfaceless(gl::Context *context); virtual egl::Error makeCurrentSurfaceless(gl::Context *context);
egl::Surface *mCurrentDrawSurface;
}; };
} // namespace rx } // namespace rx
......
...@@ -34,11 +34,6 @@ egl::Error SurfaceGL::getSyncValues(EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuin ...@@ -34,11 +34,6 @@ egl::Error SurfaceGL::getSyncValues(EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuin
return egl::EglBadSurface(); return egl::EglBadSurface();
} }
egl::Error SurfaceGL::unMakeCurrent()
{
return egl::NoError();
}
angle::Result SurfaceGL::initializeContents(const gl::Context *context, angle::Result SurfaceGL::initializeContents(const gl::Context *context,
const gl::ImageIndex &imageIndex) const gl::ImageIndex &imageIndex)
{ {
......
...@@ -26,9 +26,6 @@ class SurfaceGL : public SurfaceImpl ...@@ -26,9 +26,6 @@ class SurfaceGL : public SurfaceImpl
angle::Result initializeContents(const gl::Context *context, angle::Result initializeContents(const gl::Context *context,
const gl::ImageIndex &imageIndex) override; const gl::ImageIndex &imageIndex) override;
virtual egl::Error makeCurrent(const gl::Context *context) = 0;
virtual egl::Error unMakeCurrent();
}; };
} // namespace rx } // namespace rx
......
...@@ -39,7 +39,7 @@ class IOSurfaceSurfaceCGL : public SurfaceGL ...@@ -39,7 +39,7 @@ class IOSurfaceSurfaceCGL : public SurfaceGL
egl::Error initialize(const egl::Display *display) override; egl::Error initialize(const egl::Display *display) override;
egl::Error makeCurrent(const gl::Context *context) override; egl::Error makeCurrent(const gl::Context *context) override;
egl::Error unMakeCurrent() override; egl::Error unMakeCurrent(const gl::Context *context) override;
egl::Error swap(const gl::Context *context) override; egl::Error swap(const gl::Context *context) override;
egl::Error postSubBuffer(const gl::Context *context, egl::Error postSubBuffer(const gl::Context *context,
...@@ -67,7 +67,6 @@ class IOSurfaceSurfaceCGL : public SurfaceGL ...@@ -67,7 +67,6 @@ class IOSurfaceSurfaceCGL : public SurfaceGL
private: private:
CGLContextObj mCGLContext; CGLContextObj mCGLContext;
IOSurfaceRef mIOSurface; IOSurfaceRef mIOSurface;
const gl::Context *mCurrentContext;
int mWidth; int mWidth;
int mHeight; int mHeight;
int mPlane; int mPlane;
......
...@@ -71,7 +71,6 @@ IOSurfaceSurfaceCGL::IOSurfaceSurfaceCGL(const egl::SurfaceState &state, ...@@ -71,7 +71,6 @@ IOSurfaceSurfaceCGL::IOSurfaceSurfaceCGL(const egl::SurfaceState &state,
: SurfaceGL(state), : SurfaceGL(state),
mCGLContext(cglContext), mCGLContext(cglContext),
mIOSurface(nullptr), mIOSurface(nullptr),
mCurrentContext(nullptr),
mWidth(0), mWidth(0),
mHeight(0), mHeight(0),
mPlane(0), mPlane(0),
...@@ -108,16 +107,12 @@ egl::Error IOSurfaceSurfaceCGL::initialize(const egl::Display *display) ...@@ -108,16 +107,12 @@ egl::Error IOSurfaceSurfaceCGL::initialize(const egl::Display *display)
egl::Error IOSurfaceSurfaceCGL::makeCurrent(const gl::Context *context) egl::Error IOSurfaceSurfaceCGL::makeCurrent(const gl::Context *context)
{ {
ASSERT(!mCurrentContext);
mCurrentContext = context;
return egl::NoError(); return egl::NoError();
} }
egl::Error IOSurfaceSurfaceCGL::unMakeCurrent() egl::Error IOSurfaceSurfaceCGL::unMakeCurrent(const gl::Context *context)
{ {
ASSERT(mCurrentContext); GetFunctionsGL(context)->flush();
GetFunctionsGL(mCurrentContext)->flush();
mCurrentContext = nullptr;
return egl::NoError(); return egl::NoError();
} }
......
...@@ -359,7 +359,7 @@ egl::Error D3DTextureSurfaceWGL::makeCurrent(const gl::Context *context) ...@@ -359,7 +359,7 @@ egl::Error D3DTextureSurfaceWGL::makeCurrent(const gl::Context *context)
return egl::NoError(); return egl::NoError();
} }
egl::Error D3DTextureSurfaceWGL::unMakeCurrent() egl::Error D3DTextureSurfaceWGL::unMakeCurrent(const gl::Context *context)
{ {
if (!mFunctionsWGL->dxUnlockObjectsNV(mDeviceHandle, 1, &mBoundObjectRenderbufferHandle)) if (!mFunctionsWGL->dxUnlockObjectsNV(mDeviceHandle, 1, &mBoundObjectRenderbufferHandle))
{ {
......
...@@ -42,7 +42,7 @@ class D3DTextureSurfaceWGL : public SurfaceWGL ...@@ -42,7 +42,7 @@ class D3DTextureSurfaceWGL : public SurfaceWGL
egl::Error initialize(const egl::Display *display) override; egl::Error initialize(const egl::Display *display) override;
egl::Error makeCurrent(const gl::Context *context) override; egl::Error makeCurrent(const gl::Context *context) override;
egl::Error unMakeCurrent() override; egl::Error unMakeCurrent(const gl::Context *context) override;
egl::Error swap(const gl::Context *context) override; egl::Error swap(const gl::Context *context) override;
egl::Error postSubBuffer(const gl::Context *context, egl::Error postSubBuffer(const gl::Context *context,
......
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