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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 if (manager_->have_context_) { | 414 if (manager_->have_context_) { |
415 GLuint id = service_id(); | 415 GLuint id = service_id(); |
416 glDeleteFramebuffersEXT(1, &id); | 416 glDeleteFramebuffersEXT(1, &id); |
417 } | 417 } |
418 manager_->StopTracking(this); | 418 manager_->StopTracking(this); |
419 manager_ = NULL; | 419 manager_ = NULL; |
420 } | 420 } |
421 } | 421 } |
422 | 422 |
423 bool Framebuffer::HasUnclearedAttachment( | 423 bool Framebuffer::HasUnclearedAttachment( |
424 GLenum attachment) const { | 424 GLenum attachment_type) const { |
425 AttachmentMap::const_iterator it = | 425 const Attachment* attachment = GetAttachment(attachment_type); |
426 attachments_.find(attachment); | 426 switch (attachment_type) { |
427 if (it != attachments_.end()) { | 427 case GL_DEPTH_ATTACHMENT: |
428 const Attachment* attachment = it->second.get(); | 428 case GL_STENCIL_ATTACHMENT: |
429 return !attachment->cleared(); | 429 attachment = attachment ? attachment : |
| 430 GetAttachment(GL_DEPTH_STENCIL_ATTACHMENT); |
| 431 break; |
| 432 default: |
| 433 break; |
| 434 } |
| 435 return attachment && !attachment->cleared(); |
| 436 } |
| 437 |
| 438 bool Framebuffer::HasDepthStencilFormatAttachment() const { |
| 439 const Attachment* depth_attachment = GetAttachment(GL_DEPTH_ATTACHMENT); |
| 440 const Attachment* stencil_attachment = GetAttachment(GL_STENCIL_ATTACHMENT); |
| 441 const Attachment* depth_stencil_attachment = GetAttachment( |
| 442 GL_DEPTH_STENCIL_ATTACHMENT); |
| 443 if (depth_attachment && stencil_attachment) { |
| 444 GLenum depth_format = depth_attachment->internal_format(); |
| 445 depth_format = TextureManager::ExtractFormatFromStorageFormat(depth_format); |
| 446 GLenum stencil_format = stencil_attachment->internal_format(); |
| 447 stencil_format = TextureManager::ExtractFormatFromStorageFormat( |
| 448 stencil_format); |
| 449 return depth_format == GL_DEPTH_STENCIL && |
| 450 stencil_format == GL_DEPTH_STENCIL; |
| 451 } |
| 452 if (depth_stencil_attachment) { |
| 453 GLenum depth_stencil_format = depth_stencil_attachment->internal_format(); |
| 454 depth_stencil_format = TextureManager::ExtractFormatFromStorageFormat( |
| 455 depth_stencil_format); |
| 456 return depth_stencil_format == GL_DEPTH_STENCIL; |
430 } | 457 } |
431 return false; | 458 return false; |
432 } | 459 } |
433 | |
434 bool Framebuffer::HasDepthStencilFormatAttachment( | |
435 GLenum attachment) const { | |
436 AttachmentMap::const_iterator it = attachments_.find(attachment); | |
437 if (it != attachments_.end()) { | |
438 const Attachment* attachment = it->second.get(); | |
439 GLenum internal_format = attachment->internal_format(); | |
440 return TextureManager::ExtractFormatFromStorageFormat(internal_format) == | |
441 GL_DEPTH_STENCIL; | |
442 } | |
443 return false; | |
444 } | |
445 | 460 |
446 bool Framebuffer::HasUnclearedColorAttachments() const { | 461 bool Framebuffer::HasUnclearedColorAttachments() const { |
447 for (AttachmentMap::const_iterator it = attachments_.begin(); | 462 for (AttachmentMap::const_iterator it = attachments_.begin(); |
448 it != attachments_.end(); ++it) { | 463 it != attachments_.end(); ++it) { |
449 if (it->first >= GL_COLOR_ATTACHMENT0 && | 464 if (it->first >= GL_COLOR_ATTACHMENT0 && |
450 it->first < GL_COLOR_ATTACHMENT0 + manager_->max_draw_buffers_) { | 465 it->first < GL_COLOR_ATTACHMENT0 + manager_->max_draw_buffers_) { |
451 const Attachment* attachment = it->second.get(); | 466 const Attachment* attachment = it->second.get(); |
452 if (!attachment->cleared()) | 467 if (!attachment->cleared()) |
453 return true; | 468 return true; |
454 } | 469 } |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 | 1068 |
1054 bool FramebufferManager::IsComplete( | 1069 bool FramebufferManager::IsComplete( |
1055 Framebuffer* framebuffer) { | 1070 Framebuffer* framebuffer) { |
1056 DCHECK(framebuffer); | 1071 DCHECK(framebuffer); |
1057 return framebuffer->framebuffer_complete_state_count_id() == | 1072 return framebuffer->framebuffer_complete_state_count_id() == |
1058 framebuffer_state_change_count_; | 1073 framebuffer_state_change_count_; |
1059 } | 1074 } |
1060 | 1075 |
1061 } // namespace gles2 | 1076 } // namespace gles2 |
1062 } // namespace gpu | 1077 } // namespace gpu |
OLD | NEW |