Chromium Code Reviews| Index: gpu/command_buffer/service/framebuffer_manager.cc |
| diff --git a/gpu/command_buffer/service/framebuffer_manager.cc b/gpu/command_buffer/service/framebuffer_manager.cc |
| index 7dfba400d24704d31a79cba36c62655b1c81bba8..513a5261be75baac0b029f05399cf3e37b5ab18a 100644 |
| --- a/gpu/command_buffer/service/framebuffer_manager.cc |
| +++ b/gpu/command_buffer/service/framebuffer_manager.cc |
| @@ -360,6 +360,55 @@ bool Framebuffer::HasUnclearedAttachment( |
| return false; |
| } |
| +bool Framebuffer::HasUnclearedColorAttachments() const { |
| + for (AttachmentMap::const_iterator it = attachments_.begin(); |
| + it != attachments_.end(); ++it) { |
| + if (it->first >= GL_COLOR_ATTACHMENT0 && |
| + it->first < GL_COLOR_ATTACHMENT0 + manager_->max_draw_buffers_) { |
| + const Attachment* attachment = it->second.get(); |
| + if (!attachment->cleared()) |
| + return true; |
| + } |
| + } |
| + return false; |
| +} |
| + |
| +void Framebuffer::ChangeDrawBuffersHelper(bool recover) const { |
| + scoped_ptr<GLenum[]> buffers(new GLenum[manager_->max_draw_buffers_]); |
| + for (uint32 i = 0; i < manager_->max_draw_buffers_; ++i) |
| + buffers[i] = GL_NONE; |
| + for (AttachmentMap::const_iterator it = attachments_.begin(); |
| + it != attachments_.end(); ++it) { |
| + if (it->first >= GL_COLOR_ATTACHMENT0 && |
| + it->first < GL_COLOR_ATTACHMENT0 + manager_->max_draw_buffers_) { |
| + buffers[it->first - GL_COLOR_ATTACHMENT0] = it->first; |
| + } |
| + } |
| + bool different = false; |
| + for (uint32 i = 0; i < manager_->max_draw_buffers_; ++i) { |
| + if (buffers[i] != draw_buffers_[i]) { |
| + different = true; |
| + break; |
| + } |
| + } |
| + if (different) { |
| + if (recover) |
| + glDrawBuffersARB(manager_->max_draw_buffers_, draw_buffers_.get()); |
| + else |
| + glDrawBuffersARB(manager_->max_draw_buffers_, buffers.get()); |
|
Ken Russell (switch to Gerrit)
2014/06/05 20:00:40
Is it guaranteed that we won't try to make these c
Zhenyao Mo
2014/06/05 21:27:49
If the extension isn't available, then different s
|
| + } |
| +} |
| + |
| +void Framebuffer::PrepareDrawBuffersForClear() const { |
| + bool recover = false; |
| + ChangeDrawBuffersHelper(recover); |
| +} |
| + |
| +void Framebuffer::RecoverDrawBuffersAfterClear() const { |
| + bool recover = true; |
| + ChangeDrawBuffersHelper(recover); |
| +} |
| + |
| void Framebuffer::MarkAttachmentAsCleared( |
| RenderbufferManager* renderbuffer_manager, |
| TextureManager* texture_manager, |
| @@ -516,6 +565,8 @@ void Framebuffer::SetDrawBuffers(GLsizei n, const GLenum* bufs) { |
| draw_buffers_[i] = bufs[i]; |
| } |
| + |
| + |
|
bajones
2014/06/05 18:31:14
Could you remove this unnecessary whitespace chang
Zhenyao Mo
2014/06/05 21:27:49
There is no reason that we need three blank lines
|
| bool Framebuffer::HasAlphaMRT() const { |
| for (uint32 i = 0; i < manager_->max_draw_buffers_; ++i) { |
| if (draw_buffers_[i] != GL_NONE) { |