Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: gpu/command_buffer/service/framebuffer_manager.cc

Issue 7099007: Enforce RGB even on buggy drivers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add checks for reading GL_ALPHA_BITS etc. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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
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
46 RenderbufferManager::RenderbufferInfo* render_buffer() const { 50 RenderbufferManager::RenderbufferInfo* render_buffer() const {
47 return render_buffer_.get(); 51 return render_buffer_.get();
48 } 52 }
49 53
50 private: 54 private:
51 RenderbufferManager::RenderbufferInfo::Ref render_buffer_; 55 RenderbufferManager::RenderbufferInfo::Ref render_buffer_;
52 56
53 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment); 57 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment);
54 }; 58 };
55 59
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 96
93 virtual bool cleared() const { 97 virtual bool cleared() const {
94 // Textures are cleared on creation. 98 // Textures are cleared on creation.
95 return true; 99 return true;
96 } 100 }
97 101
98 virtual void set_cleared() { 102 virtual void set_cleared() {
99 NOTREACHED(); 103 NOTREACHED();
100 } 104 }
101 105
106 virtual bool IsTexture(TextureManager::TextureInfo* texture) const {
107 return texture == texture_.get();
108 }
109
102 TextureManager::TextureInfo* texture() const { 110 TextureManager::TextureInfo* texture() const {
103 return texture_.get(); 111 return texture_.get();
104 } 112 }
105 113
106 private: 114 private:
107 TextureManager::TextureInfo::Ref texture_; 115 TextureManager::TextureInfo::Ref texture_;
108 GLenum target_; 116 GLenum target_;
109 GLint level_; 117 GLint level_;
110 118
111 DISALLOW_COPY_AND_ASSIGN(TextureAttachment); 119 DISALLOW_COPY_AND_ASSIGN(TextureAttachment);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 void FramebufferManager::FramebufferInfo::MarkAttachedRenderbuffersAsCleared() { 170 void FramebufferManager::FramebufferInfo::MarkAttachedRenderbuffersAsCleared() {
163 for (AttachmentMap::iterator it = attachments_.begin(); 171 for (AttachmentMap::iterator it = attachments_.begin();
164 it != attachments_.end(); ++it) { 172 it != attachments_.end(); ++it) {
165 Attachment* attachment = it->second; 173 Attachment* attachment = it->second;
166 if (!attachment->cleared()) { 174 if (!attachment->cleared()) {
167 attachment->set_cleared(); 175 attachment->set_cleared();
168 } 176 }
169 } 177 }
170 } 178 }
171 179
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
172 bool FramebufferManager::FramebufferInfo::IsNotComplete() const { 199 bool FramebufferManager::FramebufferInfo::IsNotComplete() const {
173 for (AttachmentMap::const_iterator it = attachments_.begin(); 200 for (AttachmentMap::const_iterator it = attachments_.begin();
174 it != attachments_.end(); ++it) { 201 it != attachments_.end(); ++it) {
175 Attachment* attachment = it->second; 202 Attachment* attachment = it->second;
176 if (attachment->width() == 0 || attachment->height() == 0) { 203 if (attachment->width() == 0 || attachment->height() == 0) {
177 return true; 204 return true;
178 } 205 }
179 } 206 }
180 return false; 207 return false;
181 } 208 }
(...skipping 26 matching lines...) Expand all
208 } 235 }
209 } 236 }
210 237
211 void FramebufferManager::FramebufferInfo::AttachTexture( 238 void FramebufferManager::FramebufferInfo::AttachTexture(
212 GLenum attachment, TextureManager::TextureInfo* texture, GLenum target, 239 GLenum attachment, TextureManager::TextureInfo* texture, GLenum target,
213 GLint level) { 240 GLint level) {
214 DCHECK(attachment == GL_COLOR_ATTACHMENT0 || 241 DCHECK(attachment == GL_COLOR_ATTACHMENT0 ||
215 attachment == GL_DEPTH_ATTACHMENT || 242 attachment == GL_DEPTH_ATTACHMENT ||
216 attachment == GL_STENCIL_ATTACHMENT || 243 attachment == GL_STENCIL_ATTACHMENT ||
217 attachment == GL_DEPTH_STENCIL_ATTACHMENT); 244 attachment == GL_DEPTH_STENCIL_ATTACHMENT);
245 const Attachment* a = GetAttachment(attachment);
246 if (a && a->IsTexture(texture)) {
247 texture->DetachFromFramebuffer();
248 }
218 if (texture) { 249 if (texture) {
219 attachments_[attachment] = Attachment::Ref( 250 attachments_[attachment] = Attachment::Ref(
220 new TextureAttachment(texture, target, level)); 251 new TextureAttachment(texture, target, level));
252 texture->AttachToFramebuffer();
221 } else { 253 } else {
222 attachments_.erase(attachment); 254 attachments_.erase(attachment);
223 } 255 }
224 } 256 }
225 257
226 const FramebufferManager::FramebufferInfo::Attachment* 258 const FramebufferManager::FramebufferInfo::Attachment*
227 FramebufferManager::FramebufferInfo::GetAttachment( 259 FramebufferManager::FramebufferInfo::GetAttachment(
228 GLenum attachment) const { 260 GLenum attachment) const {
229 AttachmentMap::const_iterator it = attachments_.find(attachment); 261 AttachmentMap::const_iterator it = attachments_.find(attachment);
230 if (it != attachments_.end()) { 262 if (it != attachments_.end()) {
(...skipping 12 matching lines...) Expand all
243 return true; 275 return true;
244 } 276 }
245 } 277 }
246 return false; 278 return false;
247 } 279 }
248 280
249 } // namespace gles2 281 } // namespace gles2
250 } // namespace gpu 282 } // namespace gpu
251 283
252 284
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager.h ('k') | gpu/command_buffer/service/framebuffer_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698