Remove non-const FBO attachment queries.
Methods that need to mutate the Framebuffer should use
setAttachment, etc, instead of using mutable pointers.
BUG=angleproject:963
Change-Id: Ibe7b8f8245f762916e0224fdc78796b1c933195f
Reviewed-on: https://chromium-review.googlesource.com/263490
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/Framebuffer.cpp b/src/libANGLE/Framebuffer.cpp
index 3e005b3..2aadbf6 100644
--- a/src/libANGLE/Framebuffer.cpp
+++ b/src/libANGLE/Framebuffer.cpp
@@ -84,7 +84,7 @@
return nullptr;
}
-FramebufferAttachment *Framebuffer::Data::getColorAttachment(unsigned int colorAttachment)
+const FramebufferAttachment *Framebuffer::Data::getColorAttachment(unsigned int colorAttachment) const
{
ASSERT(colorAttachment < mColorAttachments.size());
return mColorAttachments[colorAttachment].isAttached() ?
@@ -92,32 +92,17 @@
nullptr;
}
-const FramebufferAttachment *Framebuffer::Data::getColorAttachment(unsigned int colorAttachment) const
-{
- return const_cast<Framebuffer::Data *>(this)->getColorAttachment(colorAttachment);
-}
-
-FramebufferAttachment *Framebuffer::Data::getDepthAttachment()
+const FramebufferAttachment *Framebuffer::Data::getDepthAttachment() const
{
return mDepthAttachment.isAttached() ? &mDepthAttachment : nullptr;
}
-const FramebufferAttachment *Framebuffer::Data::getDepthAttachment() const
-{
- return const_cast<Framebuffer::Data *>(this)->getDepthAttachment();
-}
-
-FramebufferAttachment *Framebuffer::Data::getStencilAttachment()
+const FramebufferAttachment *Framebuffer::Data::getStencilAttachment() const
{
return mStencilAttachment.isAttached() ? &mStencilAttachment : nullptr;
}
-const FramebufferAttachment *Framebuffer::Data::getStencilAttachment() const
-{
- return const_cast<Framebuffer::Data *>(this)->getStencilAttachment();
-}
-
-FramebufferAttachment *Framebuffer::Data::getDepthStencilAttachment()
+const FramebufferAttachment *Framebuffer::Data::getDepthStencilAttachment() const
{
// A valid depth-stencil attachment has the same resource bound to both the
// depth and stencil attachment points.
@@ -131,11 +116,6 @@
return nullptr;
}
-const FramebufferAttachment *Framebuffer::Data::getDepthStencilAttachment() const
-{
- return const_cast<Framebuffer::Data *>(this)->getDepthStencilAttachment();
-}
-
Framebuffer::Framebuffer(const Caps &caps, rx::ImplFactory *factory, GLuint id)
: mData(caps),
mImpl(nullptr),
@@ -178,41 +158,21 @@
DetachMatchingAttachment(&mData.mStencilAttachment, resourceType, resourceId);
}
-FramebufferAttachment *Framebuffer::getColorbuffer(unsigned int colorAttachment)
-{
- return mData.getColorAttachment(colorAttachment);
-}
-
const FramebufferAttachment *Framebuffer::getColorbuffer(unsigned int colorAttachment) const
{
return mData.getColorAttachment(colorAttachment);
}
-FramebufferAttachment *Framebuffer::getDepthbuffer()
-{
- return mData.getDepthAttachment();
-}
-
const FramebufferAttachment *Framebuffer::getDepthbuffer() const
{
return mData.getDepthAttachment();
}
-FramebufferAttachment *Framebuffer::getStencilbuffer()
-{
- return mData.getStencilAttachment();
-}
-
const FramebufferAttachment *Framebuffer::getStencilbuffer() const
{
return mData.getStencilAttachment();
}
-FramebufferAttachment *Framebuffer::getDepthStencilBuffer()
-{
- return mData.getDepthStencilAttachment();
-}
-
const FramebufferAttachment *Framebuffer::getDepthStencilBuffer() const
{
return mData.getDepthStencilAttachment();
@@ -243,7 +203,7 @@
{
if (attachment >= GL_COLOR_ATTACHMENT0 && attachment <= GL_COLOR_ATTACHMENT15)
{
- return getColorbuffer(attachment - GL_COLOR_ATTACHMENT0);
+ return mData.getColorAttachment(attachment - GL_COLOR_ATTACHMENT0);
}
else
{
@@ -251,13 +211,13 @@
{
case GL_COLOR:
case GL_BACK:
- return getColorbuffer(0);
+ return mData.getColorAttachment(0);
case GL_DEPTH:
case GL_DEPTH_ATTACHMENT:
- return getDepthbuffer();
+ return mData.getDepthAttachment();
case GL_STENCIL:
case GL_STENCIL_ATTACHMENT:
- return getStencilbuffer();
+ return mData.getStencilAttachment();
case GL_DEPTH_STENCIL:
case GL_DEPTH_STENCIL_ATTACHMENT:
return getDepthStencilBuffer();