OLD | NEW |
---|---|
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 | 197 |
198 // Check for texture fast paths. Currently we always use MO8 textures, | 198 // Check for texture fast paths. Currently we always use MO8 textures, |
199 // so we only need to avoid POT textures if we have an NPOT fast-path. | 199 // so we only need to avoid POT textures if we have an NPOT fast-path. |
200 capabilities_.avoid_pow2_textures = context_caps.fast_npot_mo8_textures; | 200 capabilities_.avoid_pow2_textures = context_caps.fast_npot_mo8_textures; |
201 | 201 |
202 capabilities_.using_offscreen_context3d = true; | 202 capabilities_.using_offscreen_context3d = true; |
203 | 203 |
204 capabilities_.using_map_image = | 204 capabilities_.using_map_image = |
205 Settings().use_map_image && context_caps.map_image; | 205 Settings().use_map_image && context_caps.map_image; |
206 | 206 |
207 capabilities_.using_discard_framebuffer = | |
208 context_caps.discard_framebuffer; | |
209 | |
207 is_using_bind_uniform_ = context_caps.bind_uniform_location; | 210 is_using_bind_uniform_ = context_caps.bind_uniform_location; |
208 | 211 |
209 if (!InitializeSharedObjects()) | 212 if (!InitializeSharedObjects()) |
210 return false; | 213 return false; |
211 | 214 |
212 // Make sure the viewport and context gets initialized, even if it is to zero. | 215 // Make sure the viewport and context gets initialized, even if it is to zero. |
213 ViewportChanged(); | 216 ViewportChanged(); |
214 return true; | 217 return true; |
215 } | 218 } |
216 | 219 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 | 289 |
287 void GLRenderer::ClearFramebuffer(DrawingFrame* frame) { | 290 void GLRenderer::ClearFramebuffer(DrawingFrame* frame) { |
288 // It's unsafe to clear when we have a stencil test because glClear ignores | 291 // It's unsafe to clear when we have a stencil test because glClear ignores |
289 // stencil. | 292 // stencil. |
290 if (client_->ExternalStencilTestEnabled() && | 293 if (client_->ExternalStencilTestEnabled() && |
291 frame->current_render_pass == frame->root_render_pass) { | 294 frame->current_render_pass == frame->root_render_pass) { |
292 DCHECK(!frame->current_render_pass->has_transparent_background); | 295 DCHECK(!frame->current_render_pass->has_transparent_background); |
293 return; | 296 return; |
294 } | 297 } |
295 | 298 |
299 if (capabilities_.using_discard_framebuffer) { | |
300 const int kNumAttachments = 1; | |
301 GLenum attachments[kNumAttachments] = { | |
piman
2013/09/04 19:23:01
nit: [] and use arraysize
| |
302 GL_COLOR_EXT | |
303 }; | |
304 context_->discardFramebufferEXT( | |
305 GL_FRAMEBUFFER, kNumAttachments, attachments); | |
306 } | |
307 | |
296 // On DEBUG builds, opaque render passes are cleared to blue to easily see | 308 // On DEBUG builds, opaque render passes are cleared to blue to easily see |
297 // regions that were not drawn on the screen. | 309 // regions that were not drawn on the screen. |
298 if (frame->current_render_pass->has_transparent_background) | 310 if (frame->current_render_pass->has_transparent_background) |
299 GLC(context_, context_->clearColor(0, 0, 0, 0)); | 311 GLC(context_, context_->clearColor(0, 0, 0, 0)); |
300 else | 312 else |
301 GLC(context_, context_->clearColor(0, 0, 1, 1)); | 313 GLC(context_, context_->clearColor(0, 0, 1, 1)); |
302 | 314 |
303 bool always_clear = false; | 315 bool always_clear = false; |
304 #ifndef NDEBUG | 316 #ifndef NDEBUG |
305 always_clear = true; | 317 always_clear = true; |
(...skipping 2844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3150 std::string unique_context_name = base::StringPrintf( | 3162 std::string unique_context_name = base::StringPrintf( |
3151 "%s-Offscreen-%p", | 3163 "%s-Offscreen-%p", |
3152 Settings().compositor_name.c_str(), | 3164 Settings().compositor_name.c_str(), |
3153 context_); | 3165 context_); |
3154 offscreen_context_provider->Context3d()->pushGroupMarkerEXT( | 3166 offscreen_context_provider->Context3d()->pushGroupMarkerEXT( |
3155 unique_context_name.c_str()); | 3167 unique_context_name.c_str()); |
3156 } | 3168 } |
3157 | 3169 |
3158 | 3170 |
3159 } // namespace cc | 3171 } // namespace cc |
OLD | NEW |