| 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/framebuffer_completeness_cache.h" | 9 #include "gpu/command_buffer/service/framebuffer_completeness_cache.h" |
| 10 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 10 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 size_t GetSignatureSize(TextureManager* texture_manager) const override { | 80 size_t GetSignatureSize(TextureManager* texture_manager) const override { |
| 81 return renderbuffer_->GetSignatureSize(); | 81 return renderbuffer_->GetSignatureSize(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void AddToSignature(TextureManager* texture_manager, | 84 void AddToSignature(TextureManager* texture_manager, |
| 85 std::string* signature) const override { | 85 std::string* signature) const override { |
| 86 DCHECK(signature); | 86 DCHECK(signature); |
| 87 renderbuffer_->AddToSignature(signature); | 87 renderbuffer_->AddToSignature(signature); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void OnWillRenderTo() const override {} | |
| 91 void OnDidRenderTo() const override {} | |
| 92 bool FormsFeedbackLoop(TextureRef* /* texture */, | 90 bool FormsFeedbackLoop(TextureRef* /* texture */, |
| 93 GLint /*level */) const override { | 91 GLint /*level */) const override { |
| 94 return false; | 92 return false; |
| 95 } | 93 } |
| 96 | 94 |
| 97 protected: | 95 protected: |
| 98 ~RenderbufferAttachment() override {} | 96 ~RenderbufferAttachment() override {} |
| 99 | 97 |
| 100 private: | 98 private: |
| 101 scoped_refptr<Renderbuffer> renderbuffer_; | 99 scoped_refptr<Renderbuffer> renderbuffer_; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 TextureRef* texture() const { | 170 TextureRef* texture() const { |
| 173 return texture_ref_.get(); | 171 return texture_ref_.get(); |
| 174 } | 172 } |
| 175 | 173 |
| 176 bool CanRenderTo() const override { | 174 bool CanRenderTo() const override { |
| 177 return texture_ref_->texture()->CanRenderTo(); | 175 return texture_ref_->texture()->CanRenderTo(); |
| 178 } | 176 } |
| 179 | 177 |
| 180 void DetachFromFramebuffer(Framebuffer* framebuffer) const override { | 178 void DetachFromFramebuffer(Framebuffer* framebuffer) const override { |
| 181 texture_ref_->texture()->DetachFromFramebuffer(); | 179 texture_ref_->texture()->DetachFromFramebuffer(); |
| 182 framebuffer->OnTextureRefDetached(texture_ref_.get()); | |
| 183 } | 180 } |
| 184 | 181 |
| 185 bool ValidForAttachmentType(GLenum attachment_type, | 182 bool ValidForAttachmentType(GLenum attachment_type, |
| 186 uint32 max_color_attachments) override { | 183 uint32 max_color_attachments) override { |
| 187 GLenum type = 0; | 184 GLenum type = 0; |
| 188 GLenum internal_format = 0; | 185 GLenum internal_format = 0; |
| 189 if (!texture_ref_->texture()->GetLevelType( | 186 if (!texture_ref_->texture()->GetLevelType( |
| 190 target_, level_, &type, &internal_format)) { | 187 target_, level_, &type, &internal_format)) { |
| 191 return false; | 188 return false; |
| 192 } | 189 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 207 return texture_manager->GetSignatureSize(); | 204 return texture_manager->GetSignatureSize(); |
| 208 } | 205 } |
| 209 | 206 |
| 210 void AddToSignature(TextureManager* texture_manager, | 207 void AddToSignature(TextureManager* texture_manager, |
| 211 std::string* signature) const override { | 208 std::string* signature) const override { |
| 212 DCHECK(signature); | 209 DCHECK(signature); |
| 213 texture_manager->AddToSignature( | 210 texture_manager->AddToSignature( |
| 214 texture_ref_.get(), target_, level_, signature); | 211 texture_ref_.get(), target_, level_, signature); |
| 215 } | 212 } |
| 216 | 213 |
| 217 void OnWillRenderTo() const override { | |
| 218 texture_ref_->texture()->OnWillModifyPixels(); | |
| 219 } | |
| 220 | |
| 221 void OnDidRenderTo() const override { | |
| 222 texture_ref_->texture()->OnDidModifyPixels(); | |
| 223 } | |
| 224 | |
| 225 bool FormsFeedbackLoop(TextureRef* texture, GLint level) const override { | 214 bool FormsFeedbackLoop(TextureRef* texture, GLint level) const override { |
| 226 return texture == texture_ref_.get() && level == level_; | 215 return texture == texture_ref_.get() && level == level_; |
| 227 } | 216 } |
| 228 | 217 |
| 229 protected: | 218 protected: |
| 230 ~TextureAttachment() override {} | 219 ~TextureAttachment() override {} |
| 231 | 220 |
| 232 private: | 221 private: |
| 233 scoped_refptr<TextureRef> texture_ref_; | 222 scoped_refptr<TextureRef> texture_ref_; |
| 234 GLenum target_; | 223 GLenum target_; |
| 235 GLint level_; | 224 GLint level_; |
| 236 GLsizei samples_; | 225 GLsizei samples_; |
| 237 | 226 |
| 238 DISALLOW_COPY_AND_ASSIGN(TextureAttachment); | 227 DISALLOW_COPY_AND_ASSIGN(TextureAttachment); |
| 239 }; | 228 }; |
| 240 | 229 |
| 241 FramebufferManager::TextureDetachObserver::TextureDetachObserver() {} | |
| 242 | |
| 243 FramebufferManager::TextureDetachObserver::~TextureDetachObserver() {} | |
| 244 | |
| 245 FramebufferManager::FramebufferManager( | 230 FramebufferManager::FramebufferManager( |
| 246 uint32 max_draw_buffers, | 231 uint32 max_draw_buffers, |
| 247 uint32 max_color_attachments, | 232 uint32 max_color_attachments, |
| 248 ContextType context_type, | 233 ContextType context_type, |
| 249 const scoped_refptr<FramebufferCompletenessCache>& | 234 const scoped_refptr<FramebufferCompletenessCache>& |
| 250 framebuffer_combo_complete_cache) | 235 framebuffer_combo_complete_cache) |
| 251 : framebuffer_state_change_count_(1), | 236 : framebuffer_state_change_count_(1), |
| 252 framebuffer_count_(0), | 237 framebuffer_count_(0), |
| 253 have_context_(true), | 238 have_context_(true), |
| 254 max_draw_buffers_(max_draw_buffers), | 239 max_draw_buffers_(max_draw_buffers), |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 } | 691 } |
| 707 return NULL; | 692 return NULL; |
| 708 } | 693 } |
| 709 | 694 |
| 710 const Framebuffer::Attachment* Framebuffer::GetReadBufferAttachment() const { | 695 const Framebuffer::Attachment* Framebuffer::GetReadBufferAttachment() const { |
| 711 if (read_buffer_ == GL_NONE) | 696 if (read_buffer_ == GL_NONE) |
| 712 return nullptr; | 697 return nullptr; |
| 713 return GetAttachment(read_buffer_); | 698 return GetAttachment(read_buffer_); |
| 714 } | 699 } |
| 715 | 700 |
| 716 void Framebuffer::OnTextureRefDetached(TextureRef* texture) { | |
| 717 manager_->OnTextureRefDetached(texture); | |
| 718 } | |
| 719 | |
| 720 void Framebuffer::OnWillRenderTo(GLenum attachment) const { | |
| 721 for (AttachmentMap::const_iterator it = attachments_.begin(); | |
| 722 it != attachments_.end(); ++it) { | |
| 723 if (attachment == 0 || attachment == it->first) { | |
| 724 it->second->OnWillRenderTo(); | |
| 725 } | |
| 726 } | |
| 727 } | |
| 728 | |
| 729 void Framebuffer::OnDidRenderTo(GLenum attachment) const { | |
| 730 for (AttachmentMap::const_iterator it = attachments_.begin(); | |
| 731 it != attachments_.end(); ++it) { | |
| 732 if (attachment == 0 || attachment == it->first) { | |
| 733 it->second->OnDidRenderTo(); | |
| 734 } | |
| 735 } | |
| 736 } | |
| 737 | |
| 738 bool FramebufferManager::GetClientId( | 701 bool FramebufferManager::GetClientId( |
| 739 GLuint service_id, GLuint* client_id) const { | 702 GLuint service_id, GLuint* client_id) const { |
| 740 // This doesn't need to be fast. It's only used during slow queries. | 703 // This doesn't need to be fast. It's only used during slow queries. |
| 741 for (FramebufferMap::const_iterator it = framebuffers_.begin(); | 704 for (FramebufferMap::const_iterator it = framebuffers_.begin(); |
| 742 it != framebuffers_.end(); ++it) { | 705 it != framebuffers_.end(); ++it) { |
| 743 if (it->second->service_id() == service_id) { | 706 if (it->second->service_id() == service_id) { |
| 744 *client_id = it->first; | 707 *client_id = it->first; |
| 745 return true; | 708 return true; |
| 746 } | 709 } |
| 747 } | 710 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 765 framebuffer->MarkAsComplete(framebuffer_state_change_count_); | 728 framebuffer->MarkAsComplete(framebuffer_state_change_count_); |
| 766 } | 729 } |
| 767 | 730 |
| 768 bool FramebufferManager::IsComplete( | 731 bool FramebufferManager::IsComplete( |
| 769 Framebuffer* framebuffer) { | 732 Framebuffer* framebuffer) { |
| 770 DCHECK(framebuffer); | 733 DCHECK(framebuffer); |
| 771 return framebuffer->framebuffer_complete_state_count_id() == | 734 return framebuffer->framebuffer_complete_state_count_id() == |
| 772 framebuffer_state_change_count_; | 735 framebuffer_state_change_count_; |
| 773 } | 736 } |
| 774 | 737 |
| 775 void FramebufferManager::OnTextureRefDetached(TextureRef* texture) { | |
| 776 for (TextureDetachObserverVector::iterator it = | |
| 777 texture_detach_observers_.begin(); | |
| 778 it != texture_detach_observers_.end(); | |
| 779 ++it) { | |
| 780 TextureDetachObserver* observer = *it; | |
| 781 observer->OnTextureRefDetachedFromFramebuffer(texture); | |
| 782 } | |
| 783 } | |
| 784 | |
| 785 } // namespace gles2 | 738 } // namespace gles2 |
| 786 } // namespace gpu | 739 } // namespace gpu |
| OLD | NEW |