Commit 6f60d05f by Jamie Madill Committed by Commit Bot

Make Framebuffer backbuffer constructor take Surface.

This allows the Framebuffer to initialize all the attachment info internally. This in turn will allow us to clean up the way we validate WebGL1 depth/stencil attachments. BUG=angleproject:1708 Change-Id: I8871a9791dfce0ac806f4e1367a521610e5283ae Reviewed-on: https://chromium-review.googlesource.com/446130Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent d83f64f5
......@@ -41,17 +41,17 @@ void BindResourceChannel(ChannelBinding *binding, FramebufferAttachmentObject *r
} // anonymous namespace
// This constructor is only used for default framebuffers.
FramebufferState::FramebufferState()
: mLabel(),
mColorAttachments(1),
mDrawBufferStates(1, GL_NONE),
mReadBufferState(GL_COLOR_ATTACHMENT0_EXT),
mDrawBufferStates(1, GL_BACK),
mReadBufferState(GL_BACK),
mDefaultWidth(0),
mDefaultHeight(0),
mDefaultSamples(0),
mDefaultFixedSampleLocations(GL_FALSE)
{
mDrawBufferStates[0] = GL_COLOR_ATTACHMENT0_EXT;
mEnabledDrawBuffers.set(0);
}
......@@ -301,9 +301,9 @@ Framebuffer::Framebuffer(const Caps &caps, rx::GLImplFactory *factory, GLuint id
}
}
Framebuffer::Framebuffer(rx::SurfaceImpl *surface)
Framebuffer::Framebuffer(egl::Surface *surface)
: mState(),
mImpl(surface->createDefaultFramebuffer(mState)),
mImpl(surface->getImplementation()->createDefaultFramebuffer(mState)),
mId(0),
mCachedStatus(GL_FRAMEBUFFER_COMPLETE),
mDirtyDepthAttachmentBinding(this, DIRTY_BIT_DEPTH_ATTACHMENT),
......@@ -312,6 +312,18 @@ Framebuffer::Framebuffer(rx::SurfaceImpl *surface)
ASSERT(mImpl != nullptr);
mDirtyColorAttachmentBindings.push_back(
ChannelBinding(this, static_cast<SignalToken>(DIRTY_BIT_COLOR_ATTACHMENT_0)));
setAttachment(GL_FRAMEBUFFER_DEFAULT, GL_BACK, gl::ImageIndex::MakeInvalid(), surface);
if (surface->getConfig()->depthSize > 0)
{
setAttachment(GL_FRAMEBUFFER_DEFAULT, GL_DEPTH, gl::ImageIndex::MakeInvalid(), surface);
}
if (surface->getConfig()->stencilSize > 0)
{
setAttachment(GL_FRAMEBUFFER_DEFAULT, GL_STENCIL, gl::ImageIndex::MakeInvalid(), surface);
}
}
Framebuffer::Framebuffer(rx::GLImplFactory *factory)
......
......@@ -113,7 +113,7 @@ class Framebuffer final : public LabeledObject, public angle::SignalReceiver
// Constructor to build application-defined framebuffers
Framebuffer(const Caps &caps, rx::GLImplFactory *factory, GLuint id);
// Constructor to build default framebuffers for a surface
Framebuffer(rx::SurfaceImpl *surface);
Framebuffer(egl::Surface *surface);
// Constructor to build a fake default framebuffer when surfaceless
Framebuffer(rx::GLImplFactory *factory);
......
......@@ -274,28 +274,7 @@ GLuint Surface::getId() const
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 (mState.config->depthSize > 0)
{
framebuffer->setAttachment(GL_FRAMEBUFFER_DEFAULT, GL_DEPTH, gl::ImageIndex::MakeInvalid(),
this);
}
if (mState.config->stencilSize > 0)
{
framebuffer->setAttachment(GL_FRAMEBUFFER_DEFAULT, GL_STENCIL,
gl::ImageIndex::MakeInvalid(), this);
}
return framebuffer;
return new gl::Framebuffer(this);
}
WindowSurface::WindowSurface(rx::EGLImplFactory *implFactory,
......
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