| 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/stringprintf.h" | 7 #include "base/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" |
| 11 #include "ui/gl/gl_bindings.h" | 11 #include "ui/gl/gl_bindings.h" |
| 12 | 12 |
| 13 namespace gpu { | 13 namespace gpu { |
| 14 namespace gles2 { | 14 namespace gles2 { |
| 15 | 15 |
| 16 Framebuffer::FramebufferComboCompleteMap* | 16 Framebuffer::FramebufferComboCompleteMap* |
| 17 Framebuffer::framebuffer_combo_complete_map_; | 17 Framebuffer::framebuffer_combo_complete_map_; |
| 18 | 18 |
| 19 // Framebuffer completeness is not cacheable on OS X because of dynamic |
| 20 // graphics switching. |
| 21 // http://crbug.com/180876 |
| 22 #if defined(OS_MACOSX) |
| 23 bool Framebuffer::allow_framebuffer_combo_complete_map_ = false; |
| 24 #else |
| 25 bool Framebuffer::allow_framebuffer_combo_complete_map_ = true; |
| 26 #endif |
| 27 |
| 19 void Framebuffer::ClearFramebufferCompleteComboMap() { | 28 void Framebuffer::ClearFramebufferCompleteComboMap() { |
| 20 if (framebuffer_combo_complete_map_) { | 29 if (framebuffer_combo_complete_map_) { |
| 21 framebuffer_combo_complete_map_->clear(); | 30 framebuffer_combo_complete_map_->clear(); |
| 22 } | 31 } |
| 23 } | 32 } |
| 24 | 33 |
| 25 class RenderbufferAttachment | 34 class RenderbufferAttachment |
| 26 : public Framebuffer::Attachment { | 35 : public Framebuffer::Attachment { |
| 27 public: | 36 public: |
| 28 explicit RenderbufferAttachment( | 37 explicit RenderbufferAttachment( |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 } | 380 } |
| 372 | 381 |
| 373 // This does not mean the framebuffer is actually complete. It just means our | 382 // This does not mean the framebuffer is actually complete. It just means our |
| 374 // checks passed. | 383 // checks passed. |
| 375 return GL_FRAMEBUFFER_COMPLETE; | 384 return GL_FRAMEBUFFER_COMPLETE; |
| 376 } | 385 } |
| 377 | 386 |
| 378 GLenum Framebuffer::GetStatus( | 387 GLenum Framebuffer::GetStatus( |
| 379 TextureManager* texture_manager, GLenum target) const { | 388 TextureManager* texture_manager, GLenum target) const { |
| 380 // Check if we have this combo already. | 389 // Check if we have this combo already. |
| 381 std::string signature(base::StringPrintf("|FBO|target=%04x", target)); | 390 std::string signature; |
| 382 for (AttachmentMap::const_iterator it = attachments_.begin(); | 391 if (allow_framebuffer_combo_complete_map_) { |
| 383 it != attachments_.end(); ++it) { | 392 signature = base::StringPrintf("|FBO|target=%04x", target); |
| 384 Attachment* attachment = it->second; | 393 for (AttachmentMap::const_iterator it = attachments_.begin(); |
| 385 signature += base::StringPrintf( | 394 it != attachments_.end(); ++it) { |
| 386 "|Attachment|attachmentpoint=%04x", it->first); | 395 Attachment* attachment = it->second; |
| 387 attachment->AddToSignature(texture_manager, &signature); | 396 signature += base::StringPrintf( |
| 397 "|Attachment|attachmentpoint=%04x", it->first); |
| 398 attachment->AddToSignature(texture_manager, &signature); |
| 399 } |
| 400 |
| 401 if (!framebuffer_combo_complete_map_) { |
| 402 framebuffer_combo_complete_map_ = new FramebufferComboCompleteMap(); |
| 403 } |
| 404 |
| 405 FramebufferComboCompleteMap::const_iterator it = |
| 406 framebuffer_combo_complete_map_->find(signature); |
| 407 if (it != framebuffer_combo_complete_map_->end()) { |
| 408 return GL_FRAMEBUFFER_COMPLETE; |
| 409 } |
| 388 } | 410 } |
| 389 | 411 |
| 390 if (!framebuffer_combo_complete_map_) { | 412 GLenum result = glCheckFramebufferStatusEXT(target); |
| 391 framebuffer_combo_complete_map_ = new FramebufferComboCompleteMap(); | 413 |
| 414 // Insert the new result into the combo map. |
| 415 if (allow_framebuffer_combo_complete_map_ && |
| 416 result == GL_FRAMEBUFFER_COMPLETE) { |
| 417 framebuffer_combo_complete_map_->insert(std::make_pair(signature, true)); |
| 392 } | 418 } |
| 393 | 419 |
| 394 FramebufferComboCompleteMap::const_iterator it = | |
| 395 framebuffer_combo_complete_map_->find(signature); | |
| 396 if (it != framebuffer_combo_complete_map_->end()) { | |
| 397 return GL_FRAMEBUFFER_COMPLETE; | |
| 398 } | |
| 399 GLenum result = glCheckFramebufferStatusEXT(target); | |
| 400 if (result == GL_FRAMEBUFFER_COMPLETE) { | |
| 401 framebuffer_combo_complete_map_->insert(std::make_pair(signature, true)); | |
| 402 } | |
| 403 return result; | 420 return result; |
| 404 } | 421 } |
| 405 | 422 |
| 406 bool Framebuffer::IsCleared() const { | 423 bool Framebuffer::IsCleared() const { |
| 407 // are all the attachments cleaared? | 424 // are all the attachments cleaared? |
| 408 for (AttachmentMap::const_iterator it = attachments_.begin(); | 425 for (AttachmentMap::const_iterator it = attachments_.begin(); |
| 409 it != attachments_.end(); ++it) { | 426 it != attachments_.end(); ++it) { |
| 410 Attachment* attachment = it->second; | 427 Attachment* attachment = it->second; |
| 411 if (!attachment->cleared()) { | 428 if (!attachment->cleared()) { |
| 412 return false; | 429 return false; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 Framebuffer* framebuffer) { | 572 Framebuffer* framebuffer) { |
| 556 DCHECK(framebuffer); | 573 DCHECK(framebuffer); |
| 557 return framebuffer->framebuffer_complete_state_count_id() == | 574 return framebuffer->framebuffer_complete_state_count_id() == |
| 558 framebuffer_state_change_count_; | 575 framebuffer_state_change_count_; |
| 559 } | 576 } |
| 560 | 577 |
| 561 } // namespace gles2 | 578 } // namespace gles2 |
| 562 } // namespace gpu | 579 } // namespace gpu |
| 563 | 580 |
| 564 | 581 |
| OLD | NEW |