Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: gpu/command_buffer/service/framebuffer_manager.cc

Issue 1412613004: Set attachment for bound framebuffer in FramebufferTextureLayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix WebGLTextureAttachment::attach Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 private: 100 private:
101 scoped_refptr<Renderbuffer> renderbuffer_; 101 scoped_refptr<Renderbuffer> renderbuffer_;
102 102
103 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment); 103 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment);
104 }; 104 };
105 105
106 class TextureAttachment 106 class TextureAttachment
107 : public Framebuffer::Attachment { 107 : public Framebuffer::Attachment {
108 public: 108 public:
109 TextureAttachment( 109 TextureAttachment(
110 TextureRef* texture_ref, GLenum target, GLint level, GLsizei samples) 110 TextureRef* texture_ref, GLenum target, GLint level,
111 GLsizei samples, GLint layer)
111 : texture_ref_(texture_ref), 112 : texture_ref_(texture_ref),
112 target_(target), 113 target_(target),
113 level_(level), 114 level_(level),
114 samples_(samples) { 115 samples_(samples),
116 layer_(layer) {
115 } 117 }
116 118
117 GLsizei width() const override { 119 GLsizei width() const override {
118 GLsizei temp_width = 0; 120 GLsizei temp_width = 0;
119 GLsizei temp_height = 0; 121 GLsizei temp_height = 0;
120 texture_ref_->texture()->GetLevelSize( 122 texture_ref_->texture()->GetLevelSize(
121 target_, level_, &temp_width, &temp_height, nullptr); 123 target_, level_, &temp_width, &temp_height, nullptr);
122 return temp_width; 124 return temp_width;
123 } 125 }
124 126
(...skipping 16 matching lines...) Expand all
141 GLenum texture_type() const override { 143 GLenum texture_type() const override {
142 GLenum temp_type = 0; 144 GLenum temp_type = 0;
143 GLenum temp_internal_format = 0; 145 GLenum temp_internal_format = 0;
144 texture_ref_->texture()->GetLevelType( 146 texture_ref_->texture()->GetLevelType(
145 target_, level_, &temp_type, &temp_internal_format); 147 target_, level_, &temp_type, &temp_internal_format);
146 return temp_type; 148 return temp_type;
147 } 149 }
148 150
149 GLsizei samples() const override { return samples_; } 151 GLsizei samples() const override { return samples_; }
150 152
153 GLint layer() const { return layer_; }
154
151 GLuint object_name() const override { return texture_ref_->client_id(); } 155 GLuint object_name() const override { return texture_ref_->client_id(); }
152 156
153 bool cleared() const override { 157 bool cleared() const override {
154 return texture_ref_->texture()->IsLevelCleared(target_, level_); 158 return texture_ref_->texture()->IsLevelCleared(target_, level_);
155 } 159 }
156 160
157 void SetCleared(RenderbufferManager* /* renderbuffer_manager */, 161 void SetCleared(RenderbufferManager* /* renderbuffer_manager */,
158 TextureManager* texture_manager, 162 TextureManager* texture_manager,
159 bool cleared) override { 163 bool cleared) override {
160 texture_manager->SetLevelCleared( 164 texture_manager->SetLevelCleared(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 231 }
228 232
229 protected: 233 protected:
230 ~TextureAttachment() override {} 234 ~TextureAttachment() override {}
231 235
232 private: 236 private:
233 scoped_refptr<TextureRef> texture_ref_; 237 scoped_refptr<TextureRef> texture_ref_;
234 GLenum target_; 238 GLenum target_;
235 GLint level_; 239 GLint level_;
236 GLsizei samples_; 240 GLsizei samples_;
241 GLint layer_;
237 242
238 DISALLOW_COPY_AND_ASSIGN(TextureAttachment); 243 DISALLOW_COPY_AND_ASSIGN(TextureAttachment);
239 }; 244 };
240 245
241 FramebufferManager::TextureDetachObserver::TextureDetachObserver() {} 246 FramebufferManager::TextureDetachObserver::TextureDetachObserver() {}
242 247
243 FramebufferManager::TextureDetachObserver::~TextureDetachObserver() {} 248 FramebufferManager::TextureDetachObserver::~TextureDetachObserver() {}
244 249
245 FramebufferManager::FramebufferManager( 250 FramebufferManager::FramebufferManager(
246 uint32 max_draw_buffers, 251 uint32 max_draw_buffers,
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 } 687 }
683 688
684 void Framebuffer::AttachTexture( 689 void Framebuffer::AttachTexture(
685 GLenum attachment, TextureRef* texture_ref, GLenum target, 690 GLenum attachment, TextureRef* texture_ref, GLenum target,
686 GLint level, GLsizei samples) { 691 GLint level, GLsizei samples) {
687 const Attachment* a = GetAttachment(attachment); 692 const Attachment* a = GetAttachment(attachment);
688 if (a) 693 if (a)
689 a->DetachFromFramebuffer(this); 694 a->DetachFromFramebuffer(this);
690 if (texture_ref) { 695 if (texture_ref) {
691 attachments_[attachment] = scoped_refptr<Attachment>( 696 attachments_[attachment] = scoped_refptr<Attachment>(
692 new TextureAttachment(texture_ref, target, level, samples)); 697 new TextureAttachment(texture_ref, target, level, samples, 0));
693 texture_ref->texture()->AttachToFramebuffer(); 698 texture_ref->texture()->AttachToFramebuffer();
694 } else { 699 } else {
695 attachments_.erase(attachment); 700 attachments_.erase(attachment);
701 }
702 framebuffer_complete_state_count_id_ = 0;
703 }
704
705 void Framebuffer::AttachTextureLayer(
706 GLenum attachment, TextureRef* texture_ref, GLenum target,
707 GLint level, GLint layer) {
708 const Attachment* a = GetAttachment(attachment);
709 if (a)
710 a->DetachFromFramebuffer(this);
711 if (texture_ref) {
712 attachments_[attachment] = scoped_refptr<Attachment>(
713 new TextureAttachment(texture_ref, target, level, 0, layer));
714 texture_ref->texture()->AttachToFramebuffer();
715 } else {
716 attachments_.erase(attachment);
696 } 717 }
697 framebuffer_complete_state_count_id_ = 0; 718 framebuffer_complete_state_count_id_ = 0;
698 } 719 }
699 720
700 const Framebuffer::Attachment* 721 const Framebuffer::Attachment*
701 Framebuffer::GetAttachment( 722 Framebuffer::GetAttachment(
702 GLenum attachment) const { 723 GLenum attachment) const {
703 AttachmentMap::const_iterator it = attachments_.find(attachment); 724 AttachmentMap::const_iterator it = attachments_.find(attachment);
704 if (it != attachments_.end()) { 725 if (it != attachments_.end()) {
705 return it->second.get(); 726 return it->second.get();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 texture_detach_observers_.begin(); 798 texture_detach_observers_.begin();
778 it != texture_detach_observers_.end(); 799 it != texture_detach_observers_.end();
779 ++it) { 800 ++it) {
780 TextureDetachObserver* observer = *it; 801 TextureDetachObserver* observer = *it;
781 observer->OnTextureRefDetachedFromFramebuffer(texture); 802 observer->OnTextureRefDetachedFromFramebuffer(texture);
782 } 803 }
783 } 804 }
784 805
785 } // namespace gles2 806 } // namespace gles2
786 } // namespace gpu 807 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698