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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( | 64 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( |
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 |
| 74 protected: |
| 75 virtual ~RenderbufferAttachment() { } |
| 76 |
76 private: | 77 private: |
77 RenderbufferManager::RenderbufferInfo::Ref renderbuffer_; | 78 RenderbufferManager::RenderbufferInfo::Ref renderbuffer_; |
78 | 79 |
79 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment); | 80 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment); |
80 }; | 81 }; |
81 | 82 |
82 class TextureAttachment | 83 class TextureAttachment |
83 : public FramebufferManager::FramebufferInfo::Attachment { | 84 : public FramebufferManager::FramebufferInfo::Attachment { |
84 public: | 85 public: |
85 TextureAttachment( | 86 TextureAttachment( |
86 TextureManager::TextureInfo* texture, GLenum target, GLint level) | 87 TextureManager::TextureInfo* texture, GLenum target, GLint level) |
87 : texture_(texture), | 88 : texture_(texture), |
88 target_(target), | 89 target_(target), |
89 level_(level) { | 90 level_(level) { |
90 } | 91 } |
91 | 92 |
92 virtual ~TextureAttachment() { } | |
93 | |
94 virtual GLsizei width() const { | 93 virtual GLsizei width() const { |
95 GLsizei temp_width = 0; | 94 GLsizei temp_width = 0; |
96 GLsizei temp_height = 0; | 95 GLsizei temp_height = 0; |
97 texture_->GetLevelSize(target_, level_, &temp_width, &temp_height); | 96 texture_->GetLevelSize(target_, level_, &temp_width, &temp_height); |
98 return temp_width; | 97 return temp_width; |
99 } | 98 } |
100 | 99 |
101 virtual GLsizei height() const { | 100 virtual GLsizei height() const { |
102 GLsizei temp_width = 0; | 101 GLsizei temp_width = 0; |
103 GLsizei temp_height = 0; | 102 GLsizei temp_height = 0; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 GLenum internal_format = 0; | 151 GLenum internal_format = 0; |
153 if (!texture_->GetLevelType(target_, level_, &type, &internal_format)) { | 152 if (!texture_->GetLevelType(target_, level_, &type, &internal_format)) { |
154 return false; | 153 return false; |
155 } | 154 } |
156 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( | 155 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( |
157 attachment_type); | 156 attachment_type); |
158 uint32 have = GLES2Util::GetChannelsForFormat(internal_format); | 157 uint32 have = GLES2Util::GetChannelsForFormat(internal_format); |
159 return (need & have) != 0; | 158 return (need & have) != 0; |
160 } | 159 } |
161 | 160 |
| 161 protected: |
| 162 virtual ~TextureAttachment() { } |
| 163 |
162 private: | 164 private: |
163 TextureManager::TextureInfo::Ref texture_; | 165 TextureManager::TextureInfo::Ref texture_; |
164 GLenum target_; | 166 GLenum target_; |
165 GLint level_; | 167 GLint level_; |
166 | 168 |
167 DISALLOW_COPY_AND_ASSIGN(TextureAttachment); | 169 DISALLOW_COPY_AND_ASSIGN(TextureAttachment); |
168 }; | 170 }; |
169 | 171 |
170 FramebufferManager::FramebufferManager() | 172 FramebufferManager::FramebufferManager() |
171 : framebuffer_state_change_count_(1), | 173 : framebuffer_state_change_count_(1), |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 FramebufferManager::FramebufferInfo* framebuffer) { | 457 FramebufferManager::FramebufferInfo* framebuffer) { |
456 DCHECK(framebuffer); | 458 DCHECK(framebuffer); |
457 return framebuffer->framebuffer_complete_state_count_id() == | 459 return framebuffer->framebuffer_complete_state_count_id() == |
458 framebuffer_state_change_count_; | 460 framebuffer_state_change_count_; |
459 } | 461 } |
460 | 462 |
461 } // namespace gles2 | 463 } // namespace gles2 |
462 } // namespace gpu | 464 } // namespace gpu |
463 | 465 |
464 | 466 |
OLD | NEW |