Index: gpu/command_buffer/service/framebuffer_manager.cc |
=================================================================== |
--- gpu/command_buffer/service/framebuffer_manager.cc (revision 187725) |
+++ gpu/command_buffer/service/framebuffer_manager.cc (working copy) |
@@ -198,10 +198,13 @@ |
DISALLOW_COPY_AND_ASSIGN(TextureAttachment); |
}; |
-FramebufferManager::FramebufferManager() |
+FramebufferManager::FramebufferManager(uint32 max_draw_buffers) |
: framebuffer_state_change_count_(1), |
framebuffer_count_(0), |
- have_context_(true) { |
+ have_context_(true), |
+ max_draw_buffers_(max_draw_buffers) { |
+ if (max_draw_buffers_ < 1) |
+ max_draw_buffers_ = 1; |
} |
FramebufferManager::~FramebufferManager() { |
@@ -254,6 +257,11 @@ |
has_been_bound_(false), |
framebuffer_complete_state_count_id_(0) { |
manager->StartTracking(this); |
+ DCHECK_GT(manager->max_draw_buffers_, 0u); |
+ draw_buffers_.reset(new GLenum[manager->max_draw_buffers_]); |
+ draw_buffers_[0] = GL_COLOR_ATTACHMENT0; |
+ for (uint32 i = 1; i < manager->max_draw_buffers_; ++i) |
+ draw_buffers_[i] = GL_NONE; |
} |
Framebuffer::~Framebuffer() { |
@@ -402,6 +410,20 @@ |
return true; |
} |
+GLenum Framebuffer::GetDrawBuffer(GLenum draw_buffer) const { |
+ GLsizei index = static_cast<GLsizei>( |
+ draw_buffer - GL_DRAW_BUFFER0_ARB); |
+ CHECK(index >= 0 && |
+ index < static_cast<GLsizei>(manager_->max_draw_buffers_)); |
+ return draw_buffers_[index]; |
+} |
+ |
+void Framebuffer::SetDrawBuffers(GLsizei n, const GLenum* bufs) { |
+ DCHECK(n <= static_cast<GLsizei>(manager_->max_draw_buffers_)); |
+ for (GLsizei i = 0; i < n; ++i) |
+ draw_buffers_[i] = bufs[i]; |
+} |
+ |
void Framebuffer::UnbindRenderbuffer( |
GLenum target, Renderbuffer* renderbuffer) { |
bool done; |
@@ -456,10 +478,6 @@ |
void Framebuffer::AttachRenderbuffer( |
GLenum attachment, Renderbuffer* renderbuffer) { |
- DCHECK(attachment == GL_COLOR_ATTACHMENT0 || |
- attachment == GL_DEPTH_ATTACHMENT || |
- attachment == GL_STENCIL_ATTACHMENT || |
- attachment == GL_DEPTH_STENCIL_ATTACHMENT); |
const Attachment* a = GetAttachment(attachment); |
if (a) |
a->DetachFromFramebuffer(); |
@@ -475,10 +493,6 @@ |
void Framebuffer::AttachTexture( |
GLenum attachment, Texture* texture, GLenum target, |
GLint level) { |
- DCHECK(attachment == GL_COLOR_ATTACHMENT0 || |
- attachment == GL_DEPTH_ATTACHMENT || |
- attachment == GL_STENCIL_ATTACHMENT || |
- attachment == GL_DEPTH_STENCIL_ATTACHMENT); |
const Attachment* a = GetAttachment(attachment); |
if (a) |
a->DetachFromFramebuffer(); |