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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 | 82 |
| 83 bool IsTextureAttachment() const override { return false; } | 83 bool IsTextureAttachment() const override { return false; } |
| 84 bool IsRenderbufferAttachment() const override { return true; } | 84 bool IsRenderbufferAttachment() const override { return true; } |
| 85 | 85 |
| 86 bool IsTexture(TextureRef* /* texture */) const override { return false; } | 86 bool IsTexture(TextureRef* /* texture */) const override { return false; } |
| 87 | 87 |
| 88 bool IsRenderbuffer(Renderbuffer* renderbuffer) const override { | 88 bool IsRenderbuffer(Renderbuffer* renderbuffer) const override { |
| 89 return renderbuffer_.get() == renderbuffer; | 89 return renderbuffer_.get() == renderbuffer; |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool IsSameAttachment(const Attachment* attachment) const override { | |
| 93 if (attachment->IsRenderbufferAttachment()) { | |
| 94 const RenderbufferAttachment* other = | |
| 95 reinterpret_cast<const RenderbufferAttachment*>(attachment); | |
| 96 return IsRenderbuffer(other->renderbuffer()); | |
| 97 } | |
| 98 return false; | |
| 99 } | |
| 100 | |
| 92 bool Is3D() const override { return false; } | 101 bool Is3D() const override { return false; } |
| 93 | 102 |
| 94 bool CanRenderTo(const FeatureInfo*) const override { return true; } | 103 bool CanRenderTo(const FeatureInfo*) const override { return true; } |
| 95 | 104 |
| 96 void DetachFromFramebuffer(Framebuffer* framebuffer) const override { | 105 void DetachFromFramebuffer(Framebuffer* framebuffer) const override { |
| 97 // Nothing to do for renderbuffers. | 106 // Nothing to do for renderbuffers. |
| 98 } | 107 } |
| 99 | 108 |
| 100 bool IsLayerValid() const override { return true; } | 109 bool IsLayerValid() const override { return true; } |
| 101 | 110 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 return texture_ref_->texture()->IsLevelPartiallyCleared(target_, level_); | 222 return texture_ref_->texture()->IsLevelPartiallyCleared(target_, level_); |
| 214 } | 223 } |
| 215 | 224 |
| 216 bool IsTextureAttachment() const override { return true; } | 225 bool IsTextureAttachment() const override { return true; } |
| 217 bool IsRenderbufferAttachment() const override { return false; } | 226 bool IsRenderbufferAttachment() const override { return false; } |
| 218 | 227 |
| 219 bool IsTexture(TextureRef* texture) const override { | 228 bool IsTexture(TextureRef* texture) const override { |
| 220 return texture == texture_ref_.get(); | 229 return texture == texture_ref_.get(); |
| 221 } | 230 } |
| 222 | 231 |
| 232 bool IsSameAttachment(const Attachment* attachment) const override { | |
| 233 if (attachment->IsTextureAttachment()) { | |
| 234 const TextureAttachment* other = | |
| 235 reinterpret_cast<const TextureAttachment*>(attachment); | |
| 236 return IsTexture(other->texture()) && | |
| 237 samples_ == other->samples() && | |
|
Zhenyao Mo
2016/07/19 20:39:15
samples should not be part of this. No matter what
qiankun
2016/07/20 08:53:33
Done.
| |
| 238 layer_ == other->layer() && | |
| 239 target_ == other->target() && | |
|
Zhenyao Mo
2016/07/19 20:39:15
This makes me think, can you add some test cases i
qiankun
2016/07/20 08:53:33
I will add test for this.
| |
| 240 level_ == other->level(); | |
| 241 } | |
| 242 return false; | |
| 243 } | |
| 244 | |
| 223 bool IsRenderbuffer(Renderbuffer* /* renderbuffer */) const override { | 245 bool IsRenderbuffer(Renderbuffer* /* renderbuffer */) const override { |
| 224 return false; | 246 return false; |
| 225 } | 247 } |
| 226 | 248 |
| 227 bool Is3D() const override { | 249 bool Is3D() const override { |
| 228 return (target_ == GL_TEXTURE_3D || target_ == GL_TEXTURE_2D_ARRAY); | 250 return (target_ == GL_TEXTURE_3D || target_ == GL_TEXTURE_2D_ARRAY); |
| 229 } | 251 } |
| 230 | 252 |
| 231 TextureRef* texture() const { | 253 TextureRef* texture() const { |
| 232 return texture_ref_.get(); | 254 return texture_ref_.get(); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 416 if (it->first >= GL_COLOR_ATTACHMENT0 && | 438 if (it->first >= GL_COLOR_ATTACHMENT0 && |
| 417 it->first < GL_COLOR_ATTACHMENT0 + manager_->max_draw_buffers_) { | 439 it->first < GL_COLOR_ATTACHMENT0 + manager_->max_draw_buffers_) { |
| 418 const Attachment* attachment = it->second.get(); | 440 const Attachment* attachment = it->second.get(); |
| 419 if (!attachment->cleared()) | 441 if (!attachment->cleared()) |
| 420 return true; | 442 return true; |
| 421 } | 443 } |
| 422 } | 444 } |
| 423 return false; | 445 return false; |
| 424 } | 446 } |
| 425 | 447 |
| 448 bool Framebuffer::HasDuplicateColorAttachments() const { | |
| 449 for (AttachmentMap::const_iterator it = attachments_.begin(); | |
| 450 it != attachments_.end(); ++it) { | |
| 451 if (it->first >= GL_COLOR_ATTACHMENT0 && | |
| 452 it->first < GL_COLOR_ATTACHMENT0 + manager_->max_draw_buffers_) { | |
|
Zhenyao Mo
2016/07/19 20:39:15
max_color_attachments_
qiankun
2016/07/20 08:53:33
That's fine.
I saw in WebGL 2.0 spec max_color_att
| |
| 453 const Attachment* attachment = it->second.get(); | |
| 454 for (GLenum i = it->first + 1; | |
| 455 i < GL_COLOR_ATTACHMENT0 + manager_->max_draw_buffers_; i++) { | |
|
Zhenyao Mo
2016/07/19 20:39:15
max_color_attachments_
| |
| 456 const Attachment* other = GetAttachment(i); | |
| 457 if (other && attachment->IsSameAttachment(other)) { | |
| 458 return true; | |
| 459 } | |
| 460 } | |
| 461 } | |
| 462 } | |
| 463 return false; | |
| 464 } | |
| 465 | |
| 426 bool Framebuffer::HasUnclearedIntRenderbufferAttachments() const { | 466 bool Framebuffer::HasUnclearedIntRenderbufferAttachments() const { |
| 427 for (AttachmentMap::const_iterator it = attachments_.begin(); | 467 for (AttachmentMap::const_iterator it = attachments_.begin(); |
| 428 it != attachments_.end(); ++it) { | 468 it != attachments_.end(); ++it) { |
| 429 if (!it->second->IsRenderbufferAttachment() || it->second->cleared()) | 469 if (!it->second->IsRenderbufferAttachment() || it->second->cleared()) |
| 430 continue; | 470 continue; |
| 431 if (GLES2Util::IsIntegerFormat(it->second->internal_format())) | 471 if (GLES2Util::IsIntegerFormat(it->second->internal_format())) |
| 432 return true; | 472 return true; |
| 433 } | 473 } |
| 434 return false; | 474 return false; |
| 435 } | 475 } |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1004 | 1044 |
| 1005 bool FramebufferManager::IsComplete( | 1045 bool FramebufferManager::IsComplete( |
| 1006 Framebuffer* framebuffer) { | 1046 Framebuffer* framebuffer) { |
| 1007 DCHECK(framebuffer); | 1047 DCHECK(framebuffer); |
| 1008 return framebuffer->framebuffer_complete_state_count_id() == | 1048 return framebuffer->framebuffer_complete_state_count_id() == |
| 1009 framebuffer_state_change_count_; | 1049 framebuffer_state_change_count_; |
| 1010 } | 1050 } |
| 1011 | 1051 |
| 1012 } // namespace gles2 | 1052 } // namespace gles2 |
| 1013 } // namespace gpu | 1053 } // namespace gpu |
| OLD | NEW |