OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/framebuffer_manager.h" | 5 #include "gpu/command_buffer/service/framebuffer_manager.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
9 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 9 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
10 #include "gpu/command_buffer/service/texture_manager.h" | 10 #include "gpu/command_buffer/service/texture_manager.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 GLsizei samples_; | 253 GLsizei samples_; |
254 | 254 |
255 DISALLOW_COPY_AND_ASSIGN(TextureAttachment); | 255 DISALLOW_COPY_AND_ASSIGN(TextureAttachment); |
256 }; | 256 }; |
257 | 257 |
258 FramebufferManager::TextureDetachObserver::TextureDetachObserver() {} | 258 FramebufferManager::TextureDetachObserver::TextureDetachObserver() {} |
259 | 259 |
260 FramebufferManager::TextureDetachObserver::~TextureDetachObserver() {} | 260 FramebufferManager::TextureDetachObserver::~TextureDetachObserver() {} |
261 | 261 |
262 FramebufferManager::FramebufferManager( | 262 FramebufferManager::FramebufferManager( |
263 uint32 max_draw_buffers, uint32 max_color_attachments) | 263 uint32 max_draw_buffers, uint32 max_color_attachments, |
| 264 ContextGroup::ContextType context_type) |
264 : framebuffer_state_change_count_(1), | 265 : framebuffer_state_change_count_(1), |
265 framebuffer_count_(0), | 266 framebuffer_count_(0), |
266 have_context_(true), | 267 have_context_(true), |
267 max_draw_buffers_(max_draw_buffers), | 268 max_draw_buffers_(max_draw_buffers), |
268 max_color_attachments_(max_color_attachments) { | 269 max_color_attachments_(max_color_attachments), |
| 270 context_type_(context_type) { |
269 DCHECK_GT(max_draw_buffers_, 0u); | 271 DCHECK_GT(max_draw_buffers_, 0u); |
270 DCHECK_GT(max_color_attachments_, 0u); | 272 DCHECK_GT(max_color_attachments_, 0u); |
271 } | 273 } |
272 | 274 |
273 FramebufferManager::~FramebufferManager() { | 275 FramebufferManager::~FramebufferManager() { |
274 DCHECK(framebuffers_.empty()); | 276 DCHECK(framebuffers_.empty()); |
275 // If this triggers, that means something is keeping a reference to a | 277 // If this triggers, that means something is keeping a reference to a |
276 // Framebuffer belonging to this. | 278 // Framebuffer belonging to this. |
277 CHECK_EQ(framebuffer_count_, 0u); | 279 CHECK_EQ(framebuffer_count_, 0u); |
278 } | 280 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 if (!attachment->ValidForAttachmentType(attachment_type, | 471 if (!attachment->ValidForAttachmentType(attachment_type, |
470 manager_->max_color_attachments_)) { | 472 manager_->max_color_attachments_)) { |
471 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 473 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
472 } | 474 } |
473 if (width < 0) { | 475 if (width < 0) { |
474 width = attachment->width(); | 476 width = attachment->width(); |
475 height = attachment->height(); | 477 height = attachment->height(); |
476 if (width == 0 || height == 0) { | 478 if (width == 0 || height == 0) { |
477 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 479 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
478 } | 480 } |
479 } else { | 481 } else if (manager_->context_type() != ContextGroup::CONTEXT_TYPE_WEBGL2) { |
| 482 // TODO(zmo): revisit this if we create ES3 contexts for clients other |
| 483 // than WebGL 2. |
480 if (attachment->width() != width || attachment->height() != height) { | 484 if (attachment->width() != width || attachment->height() != height) { |
481 return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT; | 485 return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT; |
482 } | 486 } |
483 } | 487 } |
484 | 488 |
485 if (!attachment->CanRenderTo()) { | 489 if (!attachment->CanRenderTo()) { |
486 return GL_FRAMEBUFFER_UNSUPPORTED; | 490 return GL_FRAMEBUFFER_UNSUPPORTED; |
487 } | 491 } |
488 } | 492 } |
489 | 493 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 ++it) { | 745 ++it) { |
742 TextureDetachObserver* observer = *it; | 746 TextureDetachObserver* observer = *it; |
743 observer->OnTextureRefDetachedFromFramebuffer(texture); | 747 observer->OnTextureRefDetachedFromFramebuffer(texture); |
744 } | 748 } |
745 } | 749 } |
746 | 750 |
747 } // namespace gles2 | 751 } // namespace gles2 |
748 } // namespace gpu | 752 } // namespace gpu |
749 | 753 |
750 | 754 |
OLD | NEW |