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 "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 |
12 class RenderbufferAttachment | 12 class RenderbufferAttachment |
13 : public FramebufferManager::FramebufferInfo::Attachment { | 13 : public FramebufferManager::FramebufferInfo::Attachment { |
14 public: | 14 public: |
15 explicit RenderbufferAttachment( | 15 explicit RenderbufferAttachment( |
16 RenderbufferManager::RenderbufferInfo* renderbuffer) | 16 RenderbufferManager::RenderbufferInfo* renderbuffer) |
17 : renderbuffer_(renderbuffer) { | 17 : renderbuffer_(renderbuffer) { |
18 } | 18 } |
19 | 19 |
20 virtual ~RenderbufferAttachment() { } | |
21 | |
22 virtual GLsizei width() const { | 20 virtual GLsizei width() const { |
23 return renderbuffer_->width(); | 21 return renderbuffer_->width(); |
24 } | 22 } |
25 | 23 |
26 virtual GLsizei height() const { | 24 virtual GLsizei height() const { |
27 return renderbuffer_->height(); | 25 return renderbuffer_->height(); |
28 } | 26 } |
29 | 27 |
30 virtual GLenum internal_format() const { | 28 virtual GLenum internal_format() const { |
31 return renderbuffer_->internal_format(); | 29 return renderbuffer_->internal_format(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 attachment_type); | 65 attachment_type); |
68 uint32 have = GLES2Util::GetChannelsForFormat(internal_format()); | 66 uint32 have = GLES2Util::GetChannelsForFormat(internal_format()); |
69 return (need & have) != 0; | 67 return (need & have) != 0; |
70 } | 68 } |
71 | 69 |
72 RenderbufferManager::RenderbufferInfo* renderbuffer() const { | 70 RenderbufferManager::RenderbufferInfo* renderbuffer() const { |
73 return renderbuffer_.get(); | 71 return renderbuffer_.get(); |
74 } | 72 } |
75 | 73 |
76 private: | 74 private: |
| 75 virtual ~RenderbufferAttachment() { } |
77 RenderbufferManager::RenderbufferInfo::Ref renderbuffer_; | 76 RenderbufferManager::RenderbufferInfo::Ref renderbuffer_; |
78 | 77 |
79 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment); | 78 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment); |
80 }; | 79 }; |
81 | 80 |
82 class TextureAttachment | 81 class TextureAttachment |
83 : public FramebufferManager::FramebufferInfo::Attachment { | 82 : public FramebufferManager::FramebufferInfo::Attachment { |
84 public: | 83 public: |
85 TextureAttachment( | 84 TextureAttachment( |
86 TextureManager::TextureInfo* texture, GLenum target, GLint level) | 85 TextureManager::TextureInfo* texture, GLenum target, GLint level) |
87 : texture_(texture), | 86 : texture_(texture), |
88 target_(target), | 87 target_(target), |
89 level_(level) { | 88 level_(level) { |
90 } | 89 } |
91 | 90 |
92 virtual ~TextureAttachment() { } | |
93 | |
94 virtual GLsizei width() const { | 91 virtual GLsizei width() const { |
95 GLsizei temp_width = 0; | 92 GLsizei temp_width = 0; |
96 GLsizei temp_height = 0; | 93 GLsizei temp_height = 0; |
97 texture_->GetLevelSize(target_, level_, &temp_width, &temp_height); | 94 texture_->GetLevelSize(target_, level_, &temp_width, &temp_height); |
98 return temp_width; | 95 return temp_width; |
99 } | 96 } |
100 | 97 |
101 virtual GLsizei height() const { | 98 virtual GLsizei height() const { |
102 GLsizei temp_width = 0; | 99 GLsizei temp_width = 0; |
103 GLsizei temp_height = 0; | 100 GLsizei temp_height = 0; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 if (!texture_->GetLevelType(target_, level_, &type, &internal_format)) { | 150 if (!texture_->GetLevelType(target_, level_, &type, &internal_format)) { |
154 return false; | 151 return false; |
155 } | 152 } |
156 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( | 153 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( |
157 attachment_type); | 154 attachment_type); |
158 uint32 have = GLES2Util::GetChannelsForFormat(internal_format); | 155 uint32 have = GLES2Util::GetChannelsForFormat(internal_format); |
159 return (need & have) != 0; | 156 return (need & have) != 0; |
160 } | 157 } |
161 | 158 |
162 private: | 159 private: |
| 160 virtual ~TextureAttachment() { } |
| 161 |
163 TextureManager::TextureInfo::Ref texture_; | 162 TextureManager::TextureInfo::Ref texture_; |
164 GLenum target_; | 163 GLenum target_; |
165 GLint level_; | 164 GLint level_; |
166 | 165 |
167 DISALLOW_COPY_AND_ASSIGN(TextureAttachment); | 166 DISALLOW_COPY_AND_ASSIGN(TextureAttachment); |
168 }; | 167 }; |
169 | 168 |
170 FramebufferManager::FramebufferManager() | 169 FramebufferManager::FramebufferManager() |
171 : framebuffer_state_change_count_(1), | 170 : framebuffer_state_change_count_(1), |
172 framebuffer_info_count_(0), | 171 framebuffer_info_count_(0), |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 FramebufferManager::FramebufferInfo* framebuffer) { | 454 FramebufferManager::FramebufferInfo* framebuffer) { |
456 DCHECK(framebuffer); | 455 DCHECK(framebuffer); |
457 return framebuffer->framebuffer_complete_state_count_id() == | 456 return framebuffer->framebuffer_complete_state_count_id() == |
458 framebuffer_state_change_count_; | 457 framebuffer_state_change_count_; |
459 } | 458 } |
460 | 459 |
461 } // namespace gles2 | 460 } // namespace gles2 |
462 } // namespace gpu | 461 } // namespace gpu |
463 | 462 |
464 | 463 |
OLD | NEW |