Commit 51eede9c by Nicolas Capens

Implement EGL_SWAP_BEHAVIOR for eglSurfaceAttrib().

SwiftShader currently always preserves the color buffer on eglSwapBuffers, so both EGL_BUFFER_PRESERVED and EGL_BUFFER_DESTROYED can be used without real changes. Change-Id: I55fcd7d4b4211483d8876c15d3d6ea77ea2685e6 Reviewed-on: https://swiftshader-review.googlesource.com/2721Reviewed-by: 's avatarPing-Hao Wu <pinghao@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent ebe67649
......@@ -208,6 +208,11 @@ egl::Image *Surface::getDepthStencil()
return mDepthStencil;
}
void Surface::setSwapBehavior(EGLenum swapBehavior)
{
mSwapBehavior = swapBehavior;
}
void Surface::setSwapInterval(EGLint interval)
{
if(mSwapInterval == interval)
......@@ -225,6 +230,16 @@ EGLint Surface::getConfigID() const
return mConfig->mConfigID;
}
EGLenum Surface::getSurfaceType() const
{
return mConfig->mSurfaceType;
}
sw::Format Surface::getInternalFormat() const
{
return mConfig->mRenderTargetFormat;
}
EGLint Surface::getWidth() const
{
return mWidth;
......@@ -270,11 +285,6 @@ egl::Texture *Surface::getBoundTexture() const
return mTexture;
}
sw::Format Surface::getInternalFormat() const
{
return mConfig->mRenderTargetFormat;
}
bool Surface::checkForResize()
{
#if defined(_WIN32)
......
......@@ -44,9 +44,13 @@ public:
virtual egl::Image *getRenderTarget();
virtual egl::Image *getDepthStencil();
void setSwapBehavior(EGLenum swapBehavior);
void setSwapInterval(EGLint interval);
virtual EGLint getConfigID() const;
virtual EGLenum getSurfaceType() const;
virtual sw::Format getInternalFormat() const;
virtual EGLint getWidth() const;
virtual EGLint getHeight() const;
virtual EGLint getPixelAspectRatio() const;
......@@ -54,7 +58,6 @@ public:
virtual EGLenum getSwapBehavior() const;
virtual EGLenum getTextureFormat() const;
virtual EGLenum getTextureTarget() const;
virtual sw::Format getInternalFormat() const;
virtual void setBoundTexture(egl::Texture *texture);
virtual egl::Texture *getBoundTexture() const;
......
......@@ -479,7 +479,25 @@ EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLi
return EGL_FALSE;
}
UNIMPLEMENTED(); // FIXME
switch(attribute)
{
case EGL_SWAP_BEHAVIOR:
if(value == EGL_BUFFER_PRESERVED)
{
if(!(eglSurface->getSurfaceType() && EGL_SWAP_BEHAVIOR_PRESERVED_BIT))
{
return error(EGL_BAD_MATCH, EGL_FALSE);
}
}
else if(value != EGL_BUFFER_DESTROYED)
{
return error(EGL_BAD_PARAMETER, EGL_FALSE);
}
eglSurface->setSwapBehavior(value);
break;
default:
UNIMPLEMENTED(); // FIXME
}
return success(EGL_TRUE);
}
......
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