Chromium Code Reviews| 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 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 } | 604 } |
| 605 | 605 |
| 606 bool Framebuffer::HasDepthAttachment() const { | 606 bool Framebuffer::HasDepthAttachment() const { |
| 607 return attachments_.find(GL_DEPTH_ATTACHMENT) != attachments_.end(); | 607 return attachments_.find(GL_DEPTH_ATTACHMENT) != attachments_.end(); |
| 608 } | 608 } |
| 609 | 609 |
| 610 bool Framebuffer::HasStencilAttachment() const { | 610 bool Framebuffer::HasStencilAttachment() const { |
| 611 return attachments_.find(GL_STENCIL_ATTACHMENT) != attachments_.end(); | 611 return attachments_.find(GL_STENCIL_ATTACHMENT) != attachments_.end(); |
| 612 } | 612 } |
| 613 | 613 |
| 614 bool Framebuffer::ReadBufferHasNoImage() const { | |
| 615 if (read_buffer_ == GL_NONE) { | |
| 616 return false; | |
| 617 } | |
| 618 AttachmentMap::const_iterator it = attachments_.find(read_buffer_); | |
| 619 return it == attachments_.end(); | |
| 620 } | |
| 621 | |
| 622 bool Framebuffer::DrawBuffersHaveMissingImage(GLsizei* num, GLenum* buf) const { | |
| 623 DCHECK(num); | |
| 624 DCHECK(buf); | |
| 625 bool ret = false; | |
| 626 for (GLenum i = 0; i < manager_->max_draw_buffers_; ++i) { | |
| 627 if (draw_buffers_[i] == GL_NONE) { | |
| 628 buf[i] = GL_NONE; | |
| 629 continue; | |
| 630 } | |
| 631 const Attachment* attachment = GetAttachment(draw_buffers_[i]); | |
| 632 if (attachment) { | |
| 633 buf[i] = GL_COLOR_ATTACHMENT0 + i; | |
| 634 ++(*num); | |
| 635 } else { | |
| 636 buf[i] = GL_NONE; | |
| 637 ret = true; | |
| 638 } | |
| 639 } | |
| 640 return ret; | |
| 641 } | |
| 642 | |
| 643 bool Framebuffer::ColorBuffersHaveImage() const { | |
| 644 for (GLenum i = 0; i < manager_->max_color_attachments_; i++) { | |
|
Zhenyao Mo
2016/11/16 03:27:27
Can you do the other way? i.e., go through attachm
Zhenyao Mo
2016/11/16 03:27:27
nit: ++i
| |
| 645 if (attachments_.find(GL_COLOR_ATTACHMENT0 + i) != attachments_.end()) | |
| 646 return true; | |
| 647 } | |
| 648 return false; | |
| 649 } | |
| 650 | |
| 614 GLenum Framebuffer::GetReadBufferInternalFormat() const { | 651 GLenum Framebuffer::GetReadBufferInternalFormat() const { |
| 615 if (read_buffer_ == GL_NONE) | 652 if (read_buffer_ == GL_NONE) |
| 616 return 0; | 653 return 0; |
| 617 AttachmentMap::const_iterator it = attachments_.find(read_buffer_); | 654 AttachmentMap::const_iterator it = attachments_.find(read_buffer_); |
| 618 if (it == attachments_.end()) { | 655 if (it == attachments_.end()) { |
| 619 return 0; | 656 return 0; |
| 620 } | 657 } |
| 621 const Attachment* attachment = it->second.get(); | 658 const Attachment* attachment = it->second.get(); |
| 622 if (attachment->EmulatingRGB()) { | 659 if (attachment->EmulatingRGB()) { |
| 623 DCHECK_EQ(static_cast<GLenum>(GL_RGBA), attachment->internal_format()); | 660 DCHECK_EQ(static_cast<GLenum>(GL_RGBA), attachment->internal_format()); |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1056 | 1093 |
| 1057 bool FramebufferManager::IsComplete( | 1094 bool FramebufferManager::IsComplete( |
| 1058 Framebuffer* framebuffer) { | 1095 Framebuffer* framebuffer) { |
| 1059 DCHECK(framebuffer); | 1096 DCHECK(framebuffer); |
| 1060 return framebuffer->framebuffer_complete_state_count_id() == | 1097 return framebuffer->framebuffer_complete_state_count_id() == |
| 1061 framebuffer_state_change_count_; | 1098 framebuffer_state_change_count_; |
| 1062 } | 1099 } |
| 1063 | 1100 |
| 1064 } // namespace gles2 | 1101 } // namespace gles2 |
| 1065 } // namespace gpu | 1102 } // namespace gpu |
| OLD | NEW |