OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "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 |
(...skipping 24 matching lines...) Expand all Loading... |
36 } | 36 } |
37 | 37 |
38 virtual bool cleared() const { | 38 virtual bool cleared() const { |
39 return render_buffer_->cleared(); | 39 return render_buffer_->cleared(); |
40 } | 40 } |
41 | 41 |
42 virtual void set_cleared() { | 42 virtual void set_cleared() { |
43 render_buffer_->set_cleared(); | 43 render_buffer_->set_cleared(); |
44 } | 44 } |
45 | 45 |
46 virtual bool IsTexture(TextureManager::TextureInfo* /* texture */) const { | |
47 return false; | |
48 } | |
49 | |
50 RenderbufferManager::RenderbufferInfo* render_buffer() const { | 46 RenderbufferManager::RenderbufferInfo* render_buffer() const { |
51 return render_buffer_.get(); | 47 return render_buffer_.get(); |
52 } | 48 } |
53 | 49 |
54 private: | 50 private: |
55 RenderbufferManager::RenderbufferInfo::Ref render_buffer_; | 51 RenderbufferManager::RenderbufferInfo::Ref render_buffer_; |
56 | 52 |
57 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment); | 53 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment); |
58 }; | 54 }; |
59 | 55 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 92 |
97 virtual bool cleared() const { | 93 virtual bool cleared() const { |
98 // Textures are cleared on creation. | 94 // Textures are cleared on creation. |
99 return true; | 95 return true; |
100 } | 96 } |
101 | 97 |
102 virtual void set_cleared() { | 98 virtual void set_cleared() { |
103 NOTREACHED(); | 99 NOTREACHED(); |
104 } | 100 } |
105 | 101 |
106 virtual bool IsTexture(TextureManager::TextureInfo* texture) const { | |
107 return texture == texture_.get(); | |
108 } | |
109 | |
110 TextureManager::TextureInfo* texture() const { | 102 TextureManager::TextureInfo* texture() const { |
111 return texture_.get(); | 103 return texture_.get(); |
112 } | 104 } |
113 | 105 |
114 private: | 106 private: |
115 TextureManager::TextureInfo::Ref texture_; | 107 TextureManager::TextureInfo::Ref texture_; |
116 GLenum target_; | 108 GLenum target_; |
117 GLint level_; | 109 GLint level_; |
118 | 110 |
119 DISALLOW_COPY_AND_ASSIGN(TextureAttachment); | 111 DISALLOW_COPY_AND_ASSIGN(TextureAttachment); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 void FramebufferManager::FramebufferInfo::MarkAttachedRenderbuffersAsCleared() { | 162 void FramebufferManager::FramebufferInfo::MarkAttachedRenderbuffersAsCleared() { |
171 for (AttachmentMap::iterator it = attachments_.begin(); | 163 for (AttachmentMap::iterator it = attachments_.begin(); |
172 it != attachments_.end(); ++it) { | 164 it != attachments_.end(); ++it) { |
173 Attachment* attachment = it->second; | 165 Attachment* attachment = it->second; |
174 if (!attachment->cleared()) { | 166 if (!attachment->cleared()) { |
175 attachment->set_cleared(); | 167 attachment->set_cleared(); |
176 } | 168 } |
177 } | 169 } |
178 } | 170 } |
179 | 171 |
180 bool FramebufferManager::FramebufferInfo::HasDepthAttachment() const { | |
181 return attachments_.find(GL_DEPTH_STENCIL_ATTACHMENT) != attachments_.end() || | |
182 attachments_.find(GL_DEPTH_ATTACHMENT) != attachments_.end(); | |
183 } | |
184 | |
185 bool FramebufferManager::FramebufferInfo::HasStencilAttachment() const { | |
186 return attachments_.find(GL_DEPTH_STENCIL_ATTACHMENT) != attachments_.end() || | |
187 attachments_.find(GL_STENCIL_ATTACHMENT) != attachments_.end(); | |
188 } | |
189 | |
190 GLenum FramebufferManager::FramebufferInfo::GetColorAttachmentFormat() const { | |
191 AttachmentMap::const_iterator it = attachments_.find(GL_COLOR_ATTACHMENT0); | |
192 if (it == attachments_.end()) { | |
193 return 0; | |
194 } | |
195 const Attachment* attachment = it->second; | |
196 return attachment->internal_format(); | |
197 } | |
198 | |
199 bool FramebufferManager::FramebufferInfo::IsNotComplete() const { | 172 bool FramebufferManager::FramebufferInfo::IsNotComplete() const { |
200 for (AttachmentMap::const_iterator it = attachments_.begin(); | 173 for (AttachmentMap::const_iterator it = attachments_.begin(); |
201 it != attachments_.end(); ++it) { | 174 it != attachments_.end(); ++it) { |
202 Attachment* attachment = it->second; | 175 Attachment* attachment = it->second; |
203 if (attachment->width() == 0 || attachment->height() == 0) { | 176 if (attachment->width() == 0 || attachment->height() == 0) { |
204 return true; | 177 return true; |
205 } | 178 } |
206 } | 179 } |
207 return false; | 180 return false; |
208 } | 181 } |
(...skipping 26 matching lines...) Expand all Loading... |
235 } | 208 } |
236 } | 209 } |
237 | 210 |
238 void FramebufferManager::FramebufferInfo::AttachTexture( | 211 void FramebufferManager::FramebufferInfo::AttachTexture( |
239 GLenum attachment, TextureManager::TextureInfo* texture, GLenum target, | 212 GLenum attachment, TextureManager::TextureInfo* texture, GLenum target, |
240 GLint level) { | 213 GLint level) { |
241 DCHECK(attachment == GL_COLOR_ATTACHMENT0 || | 214 DCHECK(attachment == GL_COLOR_ATTACHMENT0 || |
242 attachment == GL_DEPTH_ATTACHMENT || | 215 attachment == GL_DEPTH_ATTACHMENT || |
243 attachment == GL_STENCIL_ATTACHMENT || | 216 attachment == GL_STENCIL_ATTACHMENT || |
244 attachment == GL_DEPTH_STENCIL_ATTACHMENT); | 217 attachment == GL_DEPTH_STENCIL_ATTACHMENT); |
245 const Attachment* a = GetAttachment(attachment); | |
246 if (a && a->IsTexture(texture)) { | |
247 texture->DetachFromFramebuffer(); | |
248 } | |
249 if (texture) { | 218 if (texture) { |
250 attachments_[attachment] = Attachment::Ref( | 219 attachments_[attachment] = Attachment::Ref( |
251 new TextureAttachment(texture, target, level)); | 220 new TextureAttachment(texture, target, level)); |
252 texture->AttachToFramebuffer(); | |
253 } else { | 221 } else { |
254 attachments_.erase(attachment); | 222 attachments_.erase(attachment); |
255 } | 223 } |
256 } | 224 } |
257 | 225 |
258 const FramebufferManager::FramebufferInfo::Attachment* | 226 const FramebufferManager::FramebufferInfo::Attachment* |
259 FramebufferManager::FramebufferInfo::GetAttachment( | 227 FramebufferManager::FramebufferInfo::GetAttachment( |
260 GLenum attachment) const { | 228 GLenum attachment) const { |
261 AttachmentMap::const_iterator it = attachments_.find(attachment); | 229 AttachmentMap::const_iterator it = attachments_.find(attachment); |
262 if (it != attachments_.end()) { | 230 if (it != attachments_.end()) { |
(...skipping 12 matching lines...) Expand all Loading... |
275 return true; | 243 return true; |
276 } | 244 } |
277 } | 245 } |
278 return false; | 246 return false; |
279 } | 247 } |
280 | 248 |
281 } // namespace gles2 | 249 } // namespace gles2 |
282 } // namespace gpu | 250 } // namespace gpu |
283 | 251 |
284 | 252 |
OLD | NEW |