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)
Framebuffer *newDefault = nullptr;
if (surface != nullptr)
{
ANGLE_TRY(surface->setIsCurrent(this, true));
ANGLE_TRY(surface->makeCurrent(this));
mCurrentSurface = surface;
newDefault = surface->createDefaultFramebuffer(this);
}
......@@ -8254,7 +8254,7 @@ egl::Error Context::unsetDefaultFramebuffer()
mCurrentSurface = nullptr;
if (surface)
{
ANGLE_TRY(surface->setIsCurrent(this, false));
ANGLE_TRY(surface->unMakeCurrent(this));
}
return egl::NoError();
......
......@@ -177,14 +177,17 @@ Error Surface::initialize(const Display *display)
return NoError();
}
Error Surface::setIsCurrent(const gl::Context *context, bool isCurrent)
Error Surface::makeCurrent(const gl::Context *context)
{
if (isCurrent)
{
mRefCount++;
return NoError();
}
ANGLE_TRY(mImplementation->makeCurrent(context));
mRefCount++;
return NoError();
}
Error Surface::unMakeCurrent(const gl::Context *context)
{
ANGLE_TRY(mImplementation->unMakeCurrent(context));
return releaseRef(context->getDisplay());
}
......
......@@ -68,6 +68,8 @@ class Surface : public LabeledObject, public gl::FramebufferAttachmentObject
EGLint getType() const;
Error initialize(const Display *display);
Error makeCurrent(const gl::Context *context);
Error unMakeCurrent(const gl::Context *context);
Error swap(const gl::Context *context);
Error swapWithDamage(const gl::Context *context, EGLint *rects, EGLint n_rects);
Error postSubBuffer(const gl::Context *context,
......@@ -85,7 +87,6 @@ class Surface : public LabeledObject, public gl::FramebufferAttachmentObject
EGLint isPostSubBufferSupported() const;
void setSwapInterval(EGLint interval);
Error setIsCurrent(const gl::Context *context, bool isCurrent);
Error onDestroy(const Display *display);
void setMipmapLevel(EGLint level);
......
......@@ -15,6 +15,16 @@ SurfaceImpl::SurfaceImpl(const egl::SurfaceState &state) : mState(state) {}
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)
{
UNREACHABLE();
......
......@@ -53,6 +53,8 @@ class SurfaceImpl : public FramebufferAttachmentObjectImpl
virtual egl::Error initialize(const egl::Display *display) = 0;
virtual FramebufferImpl *createDefaultFramebuffer(const gl::Context *context,
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 swapWithDamage(const gl::Context *context, EGLint *rects, EGLint n_rects);
virtual egl::Error postSubBuffer(const gl::Context *context,
......
......@@ -22,9 +22,7 @@
namespace rx
{
DisplayGL::DisplayGL(const egl::DisplayState &state)
: DisplayImpl(state), mCurrentDrawSurface(nullptr)
{}
DisplayGL::DisplayGL(const egl::DisplayState &state) : DisplayImpl(state) {}
DisplayGL::~DisplayGL() {}
......@@ -56,14 +54,6 @@ egl::Error DisplayGL::makeCurrent(egl::Surface *drawSurface,
egl::Surface *readSurface,
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)
{
return egl::NoError();
......@@ -73,17 +63,12 @@ egl::Error DisplayGL::makeCurrent(egl::Surface *drawSurface,
ContextGL *glContext = GetImplAs<ContextGL>(context);
glContext->getStateManager()->pauseTransformFeedback();
if (drawSurface != nullptr)
{
SurfaceGL *glDrawSurface = GetImplAs<SurfaceGL>(drawSurface);
ANGLE_TRY(glDrawSurface->makeCurrent(context));
mCurrentDrawSurface = drawSurface;
return egl::NoError();
}
else
if (drawSurface == nullptr)
{
return makeCurrentSurfaceless(context);
ANGLE_TRY(makeCurrentSurfaceless(context));
}
return egl::NoError();
}
void DisplayGL::generateExtensions(egl::DisplayExtensions *outExtensions) const
......
......@@ -48,8 +48,6 @@ class DisplayGL : public DisplayImpl
private:
virtual egl::Error makeCurrentSurfaceless(gl::Context *context);
egl::Surface *mCurrentDrawSurface;
};
} // namespace rx
......
......@@ -34,11 +34,6 @@ egl::Error SurfaceGL::getSyncValues(EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuin
return egl::EglBadSurface();
}
egl::Error SurfaceGL::unMakeCurrent()
{
return egl::NoError();
}
angle::Result SurfaceGL::initializeContents(const gl::Context *context,
const gl::ImageIndex &imageIndex)
{
......
......@@ -26,9 +26,6 @@ class SurfaceGL : public SurfaceImpl
angle::Result initializeContents(const gl::Context *context,
const gl::ImageIndex &imageIndex) override;
virtual egl::Error makeCurrent(const gl::Context *context) = 0;
virtual egl::Error unMakeCurrent();
};
} // namespace rx
......
......@@ -39,7 +39,7 @@ class IOSurfaceSurfaceCGL : public SurfaceGL
egl::Error initialize(const egl::Display *display) 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 postSubBuffer(const gl::Context *context,
......@@ -67,7 +67,6 @@ class IOSurfaceSurfaceCGL : public SurfaceGL
private:
CGLContextObj mCGLContext;
IOSurfaceRef mIOSurface;
const gl::Context *mCurrentContext;
int mWidth;
int mHeight;
int mPlane;
......
......@@ -71,7 +71,6 @@ IOSurfaceSurfaceCGL::IOSurfaceSurfaceCGL(const egl::SurfaceState &state,
: SurfaceGL(state),
mCGLContext(cglContext),
mIOSurface(nullptr),
mCurrentContext(nullptr),
mWidth(0),
mHeight(0),
mPlane(0),
......@@ -108,16 +107,12 @@ egl::Error IOSurfaceSurfaceCGL::initialize(const egl::Display *display)
egl::Error IOSurfaceSurfaceCGL::makeCurrent(const gl::Context *context)
{
ASSERT(!mCurrentContext);
mCurrentContext = context;
return egl::NoError();
}
egl::Error IOSurfaceSurfaceCGL::unMakeCurrent()
egl::Error IOSurfaceSurfaceCGL::unMakeCurrent(const gl::Context *context)
{
ASSERT(mCurrentContext);
GetFunctionsGL(mCurrentContext)->flush();
mCurrentContext = nullptr;
GetFunctionsGL(context)->flush();
return egl::NoError();
}
......
......@@ -359,7 +359,7 @@ egl::Error D3DTextureSurfaceWGL::makeCurrent(const gl::Context *context)
return egl::NoError();
}
egl::Error D3DTextureSurfaceWGL::unMakeCurrent()
egl::Error D3DTextureSurfaceWGL::unMakeCurrent(const gl::Context *context)
{
if (!mFunctionsWGL->dxUnlockObjectsNV(mDeviceHandle, 1, &mBoundObjectRenderbufferHandle))
{
......
......@@ -42,7 +42,7 @@ class D3DTextureSurfaceWGL : public SurfaceWGL
egl::Error initialize(const egl::Display *display) 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 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