Create a DefaultAttachment type and an implementation for it.
This allows for dynamically sized default attachments instead of calling
Context::makeCurrent each time the surface changes size.
BUG=angle:824
Change-Id: Ic39c0d7dc4269db53a34c01c4d915cb1a3cfbd08
Reviewed-on: https://chromium-review.googlesource.com/228180
Tested-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libGLESv2/FramebufferAttachment.cpp b/src/libGLESv2/FramebufferAttachment.cpp
index 894884a..6d3b788 100644
--- a/src/libGLESv2/FramebufferAttachment.cpp
+++ b/src/libGLESv2/FramebufferAttachment.cpp
@@ -11,6 +11,7 @@
#include "libGLESv2/Texture.h"
#include "libGLESv2/formatutils.h"
#include "libGLESv2/Renderbuffer.h"
+#include "libGLESv2/renderer/FramebufferImpl.h"
#include "libGLESv2/renderer/RenderTarget.h"
#include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/renderer/d3d/TextureStorage.h"
@@ -71,11 +72,6 @@
return GetInternalFormatInfo(getActualFormat()).colorEncoding;
}
-bool FramebufferAttachment::isTexture() const
-{
- return (type() != GL_RENDERBUFFER);
-}
-
///// TextureAttachment Implementation ////////
TextureAttachment::TextureAttachment(GLenum binding, Texture *texture, const ImageIndex &index)
@@ -122,7 +118,7 @@
GLenum TextureAttachment::type() const
{
- return mIndex.type;
+ return GL_TEXTURE;
}
GLint TextureAttachment::mipLevel() const
@@ -130,6 +126,11 @@
return mIndex.mipIndex;
}
+GLenum TextureAttachment::cubeMapFace() const
+{
+ return IsCubemapTextureTarget(mIndex.type) ? mIndex.type : GL_NONE;
+}
+
GLint TextureAttachment::layer() const
{
return mIndex.layerIndex;
@@ -205,6 +206,11 @@
return 0;
}
+GLenum RenderbufferAttachment::cubeMapFace() const
+{
+ return GL_NONE;
+}
+
GLint RenderbufferAttachment::layer() const
{
return 0;
@@ -227,4 +233,90 @@
return mRenderbuffer.get();
}
+
+DefaultAttachment::DefaultAttachment(GLenum binding, rx::DefaultAttachmentImpl *impl)
+ : FramebufferAttachment(binding),
+ mImpl(impl)
+{
+ ASSERT(mImpl);
+}
+
+DefaultAttachment::~DefaultAttachment()
+{
+ SafeDelete(mImpl);
+}
+
+GLsizei DefaultAttachment::getWidth() const
+{
+ return mImpl->getWidth();
+}
+
+GLsizei DefaultAttachment::getHeight() const
+{
+ return mImpl->getHeight();
+}
+
+GLenum DefaultAttachment::getInternalFormat() const
+{
+ return mImpl->getInternalFormat();
+}
+
+GLenum DefaultAttachment::getActualFormat() const
+{
+ return mImpl->getActualFormat();
+}
+
+GLsizei DefaultAttachment::getSamples() const
+{
+ return mImpl->getSamples();
+}
+
+GLuint DefaultAttachment::id() const
+{
+ return 0;
+}
+
+GLenum DefaultAttachment::type() const
+{
+ return GL_FRAMEBUFFER_DEFAULT;
+}
+
+GLint DefaultAttachment::mipLevel() const
+{
+ return 0;
+}
+
+GLenum DefaultAttachment::cubeMapFace() const
+{
+ return GL_NONE;
+}
+
+GLint DefaultAttachment::layer() const
+{
+ return 0;
+}
+
+Texture *DefaultAttachment::getTexture()
+{
+ UNREACHABLE();
+ return NULL;
+}
+
+const ImageIndex *DefaultAttachment::getTextureImageIndex() const
+{
+ UNREACHABLE();
+ return NULL;
+}
+
+Renderbuffer *DefaultAttachment::getRenderbuffer()
+{
+ UNREACHABLE();
+ return NULL;
+}
+
+rx::DefaultAttachmentImpl *DefaultAttachment::getImplementation() const
+{
+ return mImpl;
+}
+
}