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 #include "base/logging.h" | 6 #include "base/logging.h" |
|
tfarina
2012/09/08 02:41:46
sort!
| |
| 7 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 7 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 8 | 8 |
| 9 namespace gpu { | 9 namespace gpu { |
| 10 namespace gles2 { | 10 namespace gles2 { |
| 11 | 11 |
| 12 class RenderbufferAttachment | 12 class RenderbufferAttachment |
| 13 : public FramebufferManager::FramebufferInfo::Attachment { | 13 : public FramebufferManager::FramebufferInfo::Attachment { |
| 14 public: | 14 public: |
| 15 explicit RenderbufferAttachment( | 15 explicit RenderbufferAttachment( |
| 16 RenderbufferManager::RenderbufferInfo* renderbuffer) | 16 RenderbufferManager::RenderbufferInfo* renderbuffer) |
| 17 : renderbuffer_(renderbuffer) { | 17 : renderbuffer_(renderbuffer) { |
| 18 } | 18 } |
| 19 | 19 |
| 20 virtual GLsizei width() const { | 20 virtual GLsizei width() const OVERRIDE { |
| 21 return renderbuffer_->width(); | 21 return renderbuffer_->width(); |
| 22 } | 22 } |
| 23 | 23 |
| 24 virtual GLsizei height() const { | 24 virtual GLsizei height() const OVERRIDE { |
| 25 return renderbuffer_->height(); | 25 return renderbuffer_->height(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 virtual GLenum internal_format() const { | 28 virtual GLenum internal_format() const OVERRIDE { |
| 29 return renderbuffer_->internal_format(); | 29 return renderbuffer_->internal_format(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 virtual GLsizei samples() const { | 32 virtual GLsizei samples() const OVERRIDE { |
| 33 return renderbuffer_->samples(); | 33 return renderbuffer_->samples(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 virtual bool cleared() const { | 36 virtual bool cleared() const OVERRIDE { |
| 37 return renderbuffer_->cleared(); | 37 return renderbuffer_->cleared(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 virtual void SetCleared( | 40 virtual void SetCleared( |
| 41 RenderbufferManager* renderbuffer_manager, | 41 RenderbufferManager* renderbuffer_manager, |
| 42 TextureManager* /* texture_manager */) { | 42 TextureManager* /* texture_manager */) OVERRIDE { |
| 43 renderbuffer_manager->SetCleared(renderbuffer_); | 43 renderbuffer_manager->SetCleared(renderbuffer_); |
| 44 } | 44 } |
| 45 | 45 |
| 46 virtual bool IsTexture(TextureManager::TextureInfo* /* texture */) const { | 46 virtual bool IsTexture( |
| 47 TextureManager::TextureInfo* /* texture */) const OVERRIDE { | |
| 47 return false; | 48 return false; |
| 48 } | 49 } |
| 49 | 50 |
| 50 virtual bool IsRenderbuffer( | 51 virtual bool IsRenderbuffer( |
| 51 RenderbufferManager::RenderbufferInfo* renderbuffer) const { | 52 RenderbufferManager::RenderbufferInfo* renderbuffer) const OVERRIDE { |
| 52 return renderbuffer_ == renderbuffer; | 53 return renderbuffer_ == renderbuffer; |
| 53 } | 54 } |
| 54 | 55 |
| 55 virtual bool CanRenderTo() const { | 56 virtual bool CanRenderTo() const OVERRIDE { |
| 56 return true; | 57 return true; |
| 57 } | 58 } |
| 58 | 59 |
| 59 virtual void DetachFromFramebuffer() { | 60 virtual void DetachFromFramebuffer() OVERRIDE { |
| 60 // Nothing to do for renderbuffers. | 61 // Nothing to do for renderbuffers. |
| 61 } | 62 } |
| 62 | 63 |
| 63 virtual bool ValidForAttachmentType(GLenum attachment_type) { | 64 virtual bool ValidForAttachmentType(GLenum attachment_type) OVERRIDE { |
| 64 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( | 65 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( |
| 65 attachment_type); | 66 attachment_type); |
| 66 uint32 have = GLES2Util::GetChannelsForFormat(internal_format()); | 67 uint32 have = GLES2Util::GetChannelsForFormat(internal_format()); |
| 67 return (need & have) != 0; | 68 return (need & have) != 0; |
| 68 } | 69 } |
| 69 | 70 |
| 70 RenderbufferManager::RenderbufferInfo* renderbuffer() const { | 71 RenderbufferManager::RenderbufferInfo* renderbuffer() const { |
| 71 return renderbuffer_.get(); | 72 return renderbuffer_.get(); |
| 72 } | 73 } |
| 73 | 74 |
| 74 protected: | 75 protected: |
| 75 virtual ~RenderbufferAttachment() { } | 76 virtual ~RenderbufferAttachment() { } |
| 76 | 77 |
| 77 private: | 78 private: |
| 78 RenderbufferManager::RenderbufferInfo::Ref renderbuffer_; | 79 RenderbufferManager::RenderbufferInfo::Ref renderbuffer_; |
| 79 | 80 |
| 80 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment); | 81 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment); |
| 81 }; | 82 }; |
| 82 | 83 |
| 83 class TextureAttachment | 84 class TextureAttachment |
| 84 : public FramebufferManager::FramebufferInfo::Attachment { | 85 : public FramebufferManager::FramebufferInfo::Attachment { |
| 85 public: | 86 public: |
| 86 TextureAttachment( | 87 TextureAttachment( |
| 87 TextureManager::TextureInfo* texture, GLenum target, GLint level) | 88 TextureManager::TextureInfo* texture, GLenum target, GLint level) |
| 88 : texture_(texture), | 89 : texture_(texture), |
| 89 target_(target), | 90 target_(target), |
| 90 level_(level) { | 91 level_(level) { |
| 91 } | 92 } |
| 92 | 93 |
| 93 virtual GLsizei width() const { | 94 virtual GLsizei width() const OVERRIDE { |
| 94 GLsizei temp_width = 0; | 95 GLsizei temp_width = 0; |
| 95 GLsizei temp_height = 0; | 96 GLsizei temp_height = 0; |
| 96 texture_->GetLevelSize(target_, level_, &temp_width, &temp_height); | 97 texture_->GetLevelSize(target_, level_, &temp_width, &temp_height); |
| 97 return temp_width; | 98 return temp_width; |
| 98 } | 99 } |
| 99 | 100 |
| 100 virtual GLsizei height() const { | 101 virtual GLsizei height() const OVERRIDE { |
| 101 GLsizei temp_width = 0; | 102 GLsizei temp_width = 0; |
| 102 GLsizei temp_height = 0; | 103 GLsizei temp_height = 0; |
| 103 texture_->GetLevelSize(target_, level_, &temp_width, &temp_height); | 104 texture_->GetLevelSize(target_, level_, &temp_width, &temp_height); |
| 104 return temp_height; | 105 return temp_height; |
| 105 } | 106 } |
| 106 | 107 |
| 107 virtual GLenum internal_format() const { | 108 virtual GLenum internal_format() const OVERRIDE { |
| 108 GLenum temp_type = 0; | 109 GLenum temp_type = 0; |
| 109 GLenum temp_internal_format = 0; | 110 GLenum temp_internal_format = 0; |
| 110 texture_->GetLevelType(target_, level_, &temp_type, &temp_internal_format); | 111 texture_->GetLevelType(target_, level_, &temp_type, &temp_internal_format); |
| 111 return temp_internal_format; | 112 return temp_internal_format; |
| 112 } | 113 } |
| 113 | 114 |
| 114 virtual GLsizei samples() const { | 115 virtual GLsizei samples() const OVERRIDE { |
| 115 return 0; | 116 return 0; |
| 116 } | 117 } |
| 117 | 118 |
| 118 virtual bool cleared() const { | 119 virtual bool cleared() const OVERRIDE { |
| 119 return texture_->IsLevelCleared(target_, level_); | 120 return texture_->IsLevelCleared(target_, level_); |
| 120 } | 121 } |
| 121 | 122 |
| 122 virtual void SetCleared( | 123 virtual void SetCleared( |
| 123 RenderbufferManager* /* renderbuffer_manager */, | 124 RenderbufferManager* /* renderbuffer_manager */, |
| 124 TextureManager* texture_manager) { | 125 TextureManager* texture_manager) OVERRIDE { |
| 125 texture_manager->SetLevelCleared(texture_, target_, level_); | 126 texture_manager->SetLevelCleared(texture_, target_, level_); |
| 126 } | 127 } |
| 127 | 128 |
| 128 virtual bool IsTexture(TextureManager::TextureInfo* texture) const { | 129 virtual bool IsTexture(TextureManager::TextureInfo* texture) const OVERRIDE { |
| 129 return texture == texture_.get(); | 130 return texture == texture_.get(); |
| 130 } | 131 } |
| 131 | 132 |
| 132 virtual bool IsRenderbuffer( | 133 virtual bool IsRenderbuffer( |
| 133 RenderbufferManager::RenderbufferInfo* /* renderbuffer */) const { | 134 RenderbufferManager::RenderbufferInfo* /* renderbuffer */) |
| 135 const OVERRIDE { | |
| 134 return false; | 136 return false; |
| 135 } | 137 } |
| 136 | 138 |
| 137 TextureManager::TextureInfo* texture() const { | 139 TextureManager::TextureInfo* texture() const { |
| 138 return texture_.get(); | 140 return texture_.get(); |
| 139 } | 141 } |
| 140 | 142 |
| 141 virtual bool CanRenderTo() const { | 143 virtual bool CanRenderTo() const OVERRIDE { |
| 142 return texture_->CanRenderTo(); | 144 return texture_->CanRenderTo(); |
| 143 } | 145 } |
| 144 | 146 |
| 145 virtual void DetachFromFramebuffer() { | 147 virtual void DetachFromFramebuffer() OVERRIDE { |
| 146 texture_->DetachFromFramebuffer(); | 148 texture_->DetachFromFramebuffer(); |
| 147 } | 149 } |
| 148 | 150 |
| 149 virtual bool ValidForAttachmentType(GLenum attachment_type) { | 151 virtual bool ValidForAttachmentType(GLenum attachment_type) OVERRIDE { |
| 150 GLenum type = 0; | 152 GLenum type = 0; |
| 151 GLenum internal_format = 0; | 153 GLenum internal_format = 0; |
| 152 if (!texture_->GetLevelType(target_, level_, &type, &internal_format)) { | 154 if (!texture_->GetLevelType(target_, level_, &type, &internal_format)) { |
| 153 return false; | 155 return false; |
| 154 } | 156 } |
| 155 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( | 157 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( |
| 156 attachment_type); | 158 attachment_type); |
| 157 uint32 have = GLES2Util::GetChannelsForFormat(internal_format); | 159 uint32 have = GLES2Util::GetChannelsForFormat(internal_format); |
| 158 return (need & have) != 0; | 160 return (need & have) != 0; |
| 159 } | 161 } |
| 160 | 162 |
| 161 protected: | 163 protected: |
| 162 virtual ~TextureAttachment() { } | 164 virtual ~TextureAttachment() {} |
| 163 | 165 |
| 164 private: | 166 private: |
| 165 TextureManager::TextureInfo::Ref texture_; | 167 TextureManager::TextureInfo::Ref texture_; |
| 166 GLenum target_; | 168 GLenum target_; |
| 167 GLint level_; | 169 GLint level_; |
| 168 | 170 |
| 169 DISALLOW_COPY_AND_ASSIGN(TextureAttachment); | 171 DISALLOW_COPY_AND_ASSIGN(TextureAttachment); |
| 170 }; | 172 }; |
| 171 | 173 |
| 172 FramebufferManager::FramebufferManager() | 174 FramebufferManager::FramebufferManager() |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 FramebufferManager::FramebufferInfo* framebuffer) { | 459 FramebufferManager::FramebufferInfo* framebuffer) { |
| 458 DCHECK(framebuffer); | 460 DCHECK(framebuffer); |
| 459 return framebuffer->framebuffer_complete_state_count_id() == | 461 return framebuffer->framebuffer_complete_state_count_id() == |
| 460 framebuffer_state_change_count_; | 462 framebuffer_state_change_count_; |
| 461 } | 463 } |
| 462 | 464 |
| 463 } // namespace gles2 | 465 } // namespace gles2 |
| 464 } // namespace gpu | 466 } // namespace gpu |
| 465 | 467 |
| 466 | 468 |
| OLD | NEW |