summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/libANGLE/Surface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/angle/src/libANGLE/Surface.cpp')
-rw-r--r--src/3rdparty/angle/src/libANGLE/Surface.cpp137
1 files changed, 116 insertions, 21 deletions
diff --git a/src/3rdparty/angle/src/libANGLE/Surface.cpp b/src/3rdparty/angle/src/libANGLE/Surface.cpp
index ac455f3905..b5ed0ff5a6 100644
--- a/src/3rdparty/angle/src/libANGLE/Surface.cpp
+++ b/src/3rdparty/angle/src/libANGLE/Surface.cpp
@@ -11,17 +11,25 @@
#include "libANGLE/Surface.h"
#include "libANGLE/Config.h"
+#include "libANGLE/Framebuffer.h"
#include "libANGLE/Texture.h"
-#include "libANGLE/renderer/SurfaceImpl.h"
#include <EGL/eglext.h>
+#include <iostream>
+
namespace egl
{
-Surface::Surface(rx::SurfaceImpl *impl, EGLint surfaceType, const egl::Config *config, const AttributeMap &attributes)
- : RefCountObject(0), // id unused
+Surface::Surface(rx::SurfaceImpl *impl,
+ EGLint surfaceType,
+ const egl::Config *config,
+ const AttributeMap &attributes)
+ : FramebufferAttachmentObject(),
mImplementation(impl),
+ mDefaultFramebuffer(nullptr),
+ mCurrentCount(0),
+ mDestroyed(false),
mType(surfaceType),
mConfig(config),
mPostSubBufferRequested(false),
@@ -33,12 +41,15 @@ Surface::Surface(rx::SurfaceImpl *impl, EGLint surfaceType, const egl::Config *c
// FIXME: Determine actual pixel aspect ratio
mPixelAspectRatio(static_cast<EGLint>(1.0 * EGL_DISPLAY_SCALING)),
mRenderBuffer(EGL_BACK_BUFFER),
- mSwapBehavior(EGL_BUFFER_PRESERVED),
- mTexture(NULL)
+ mSwapBehavior(impl->getSwapBehavior()),
+ mOrientation(0),
+ mTexture()
{
- addRef();
-
mPostSubBufferRequested = (attributes.get(EGL_POST_SUB_BUFFER_SUPPORTED_NV, EGL_FALSE) == EGL_TRUE);
+ mFlexibleSurfaceCompatibilityRequested =
+ (attributes.get(EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE, EGL_FALSE) == EGL_TRUE);
+
+ mDirectComposition = (attributes.get(EGL_DIRECT_COMPOSITION_ANGLE, EGL_FALSE) == EGL_TRUE);
mFixedSize = (attributes.get(EGL_FIXED_SIZE_ANGLE, EGL_FALSE) == EGL_TRUE);
if (mFixedSize)
@@ -52,23 +63,55 @@ Surface::Surface(rx::SurfaceImpl *impl, EGLint surfaceType, const egl::Config *c
mTextureFormat = attributes.get(EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE);
mTextureTarget = attributes.get(EGL_TEXTURE_TARGET, EGL_NO_TEXTURE);
}
+
+ mOrientation = attributes.get(EGL_SURFACE_ORIENTATION_ANGLE, 0);
+
+ mDefaultFramebuffer = createDefaultFramebuffer();
+ ASSERT(mDefaultFramebuffer != nullptr);
}
Surface::~Surface()
{
- if (mTexture)
+ if (mTexture.get())
{
if (mImplementation)
{
- mImplementation->releaseTexImage(mTexture->id());
+ mImplementation->releaseTexImage(EGL_BACK_BUFFER);
}
- mTexture->releaseTexImage();
- mTexture = NULL;
+ mTexture->releaseTexImageFromSurface();
+ mTexture.set(nullptr);
}
+ SafeDelete(mDefaultFramebuffer);
SafeDelete(mImplementation);
}
+void Surface::setIsCurrent(bool isCurrent)
+{
+ if (isCurrent)
+ {
+ mCurrentCount++;
+ }
+ else
+ {
+ ASSERT(mCurrentCount > 0);
+ mCurrentCount--;
+ if (mCurrentCount == 0 && mDestroyed)
+ {
+ delete this;
+ }
+ }
+}
+
+void Surface::onDestroy()
+{
+ mDestroyed = true;
+ if (mCurrentCount == 0)
+ {
+ delete this;
+ }
+}
+
EGLint Surface::getType() const
{
return mType;
@@ -136,31 +179,83 @@ EGLint Surface::isFixedSize() const
EGLint Surface::getWidth() const
{
- return mFixedSize ? mFixedWidth : mImplementation->getWidth();
+ return mFixedSize ? static_cast<EGLint>(mFixedWidth) : mImplementation->getWidth();
}
EGLint Surface::getHeight() const
{
- return mFixedSize ? mFixedHeight : mImplementation->getHeight();
+ return mFixedSize ? static_cast<EGLint>(mFixedHeight) : mImplementation->getHeight();
}
Error Surface::bindTexImage(gl::Texture *texture, EGLint buffer)
{
- ASSERT(!mTexture);
+ ASSERT(!mTexture.get());
- texture->bindTexImage(this);
- mTexture = texture;
- return mImplementation->bindTexImage(buffer);
+ texture->bindTexImageFromSurface(this);
+ mTexture.set(texture);
+ return mImplementation->bindTexImage(texture, buffer);
}
Error Surface::releaseTexImage(EGLint buffer)
{
- ASSERT(mTexture);
- gl::Texture *boundTexture = mTexture;
- mTexture = NULL;
+ ASSERT(mTexture.get());
+ mTexture->releaseTexImageFromSurface();
+ mTexture.set(nullptr);
- boundTexture->releaseTexImage();
return mImplementation->releaseTexImage(buffer);
}
+void Surface::releaseTexImageFromTexture()
+{
+ ASSERT(mTexture.get());
+ mTexture.set(nullptr);
+}
+
+gl::Extents Surface::getAttachmentSize(const gl::FramebufferAttachment::Target & /*target*/) const
+{
+ return gl::Extents(getWidth(), getHeight(), 1);
+}
+
+GLenum Surface::getAttachmentInternalFormat(const gl::FramebufferAttachment::Target &target) const
+{
+ const egl::Config *config = getConfig();
+ return (target.binding() == GL_BACK ? config->renderTargetFormat : config->depthStencilFormat);
+}
+
+GLsizei Surface::getAttachmentSamples(const gl::FramebufferAttachment::Target &target) const
+{
+ return getConfig()->samples;
+}
+
+GLuint Surface::getId() const
+{
+ UNREACHABLE();
+ return 0;
+}
+
+gl::Framebuffer *Surface::createDefaultFramebuffer()
+{
+ gl::Framebuffer *framebuffer = new gl::Framebuffer(mImplementation);
+
+ GLenum drawBufferState = GL_BACK;
+ framebuffer->setDrawBuffers(1, &drawBufferState);
+ framebuffer->setReadBuffer(GL_BACK);
+
+ framebuffer->setAttachment(GL_FRAMEBUFFER_DEFAULT, GL_BACK, gl::ImageIndex::MakeInvalid(),
+ this);
+
+ if (mConfig->depthSize > 0)
+ {
+ framebuffer->setAttachment(GL_FRAMEBUFFER_DEFAULT, GL_DEPTH, gl::ImageIndex::MakeInvalid(),
+ this);
+ }
+
+ if (mConfig->stencilSize > 0)
+ {
+ framebuffer->setAttachment(GL_FRAMEBUFFER_DEFAULT, GL_STENCIL,
+ gl::ImageIndex::MakeInvalid(), this);
+ }
+
+ return framebuffer;
+}
}