| 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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 } | 394 } |
| 395 | 395 |
| 396 void GLRenderer::DidChangeVisibility() { | 396 void GLRenderer::DidChangeVisibility() { |
| 397 EnforceMemoryPolicy(); | 397 EnforceMemoryPolicy(); |
| 398 | 398 |
| 399 context_support_->SetSurfaceVisible(visible()); | 399 context_support_->SetSurfaceVisible(visible()); |
| 400 } | 400 } |
| 401 | 401 |
| 402 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } | 402 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } |
| 403 | 403 |
| 404 void GLRenderer::DiscardPixels(bool has_external_stencil_test, | 404 void GLRenderer::DiscardPixels() { |
| 405 bool draw_rect_covers_full_surface) { | 405 if (!capabilities_.using_discard_framebuffer) |
| 406 if (has_external_stencil_test || !draw_rect_covers_full_surface || | |
| 407 !capabilities_.using_discard_framebuffer) | |
| 408 return; | 406 return; |
| 409 bool using_default_framebuffer = | 407 bool using_default_framebuffer = |
| 410 !current_framebuffer_lock_ && | 408 !current_framebuffer_lock_ && |
| 411 output_surface_->capabilities().uses_default_gl_framebuffer; | 409 output_surface_->capabilities().uses_default_gl_framebuffer; |
| 412 GLenum attachments[] = {static_cast<GLenum>( | 410 GLenum attachments[] = {static_cast<GLenum>( |
| 413 using_default_framebuffer ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0_EXT)}; | 411 using_default_framebuffer ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0_EXT)}; |
| 414 gl_->DiscardFramebufferEXT( | 412 gl_->DiscardFramebufferEXT( |
| 415 GL_FRAMEBUFFER, arraysize(attachments), attachments); | 413 GL_FRAMEBUFFER, arraysize(attachments), attachments); |
| 416 } | 414 } |
| 417 | 415 |
| 418 void GLRenderer::ClearFramebuffer(DrawingFrame* frame, | 416 void GLRenderer::PrepareSurfaceForPass( |
| 419 bool has_external_stencil_test) { | 417 DrawingFrame* frame, |
| 420 // It's unsafe to clear when we have a stencil test because glClear ignores | 418 SurfaceInitializationMode initialization_mode, |
| 421 // stencil. | 419 const gfx::Rect& render_pass_scissor) { |
| 422 if (has_external_stencil_test) { | 420 switch (initialization_mode) { |
| 423 DCHECK(!frame->current_render_pass->has_transparent_background); | 421 case SURFACE_INITIALIZATION_MODE_PRESERVE: |
| 424 return; | 422 EnsureScissorTestDisabled(); |
| 423 return; |
| 424 case SURFACE_INITIALIZATION_MODE_FULL_SURFACE_CLEAR: |
| 425 EnsureScissorTestDisabled(); |
| 426 DiscardPixels(); |
| 427 ClearFramebuffer(frame); |
| 428 break; |
| 429 case SURFACE_INITIALIZATION_MODE_SCISSORED_CLEAR: |
| 430 SetScissorTestRect(render_pass_scissor); |
| 431 ClearFramebuffer(frame); |
| 432 break; |
| 425 } | 433 } |
| 434 } |
| 426 | 435 |
| 436 void GLRenderer::ClearFramebuffer(DrawingFrame* frame) { |
| 427 // On DEBUG builds, opaque render passes are cleared to blue to easily see | 437 // On DEBUG builds, opaque render passes are cleared to blue to easily see |
| 428 // regions that were not drawn on the screen. | 438 // regions that were not drawn on the screen. |
| 429 if (frame->current_render_pass->has_transparent_background) | 439 if (frame->current_render_pass->has_transparent_background) |
| 430 GLC(gl_, gl_->ClearColor(0, 0, 0, 0)); | 440 GLC(gl_, gl_->ClearColor(0, 0, 0, 0)); |
| 431 else | 441 else |
| 432 GLC(gl_, gl_->ClearColor(0, 0, 1, 1)); | 442 GLC(gl_, gl_->ClearColor(0, 0, 1, 1)); |
| 433 | 443 |
| 434 bool always_clear = false; | 444 bool always_clear = false; |
| 435 #ifndef NDEBUG | 445 #ifndef NDEBUG |
| 436 always_clear = true; | 446 always_clear = true; |
| (...skipping 2476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2913 make_scoped_ptr(new ResourceProvider::ScopedWriteLockGL( | 2923 make_scoped_ptr(new ResourceProvider::ScopedWriteLockGL( |
| 2914 resource_provider_, texture->id())); | 2924 resource_provider_, texture->id())); |
| 2915 unsigned texture_id = current_framebuffer_lock_->texture_id(); | 2925 unsigned texture_id = current_framebuffer_lock_->texture_id(); |
| 2916 GLC(gl_, | 2926 GLC(gl_, |
| 2917 gl_->FramebufferTexture2D( | 2927 gl_->FramebufferTexture2D( |
| 2918 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0)); | 2928 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0)); |
| 2919 | 2929 |
| 2920 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) == | 2930 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) == |
| 2921 GL_FRAMEBUFFER_COMPLETE || | 2931 GL_FRAMEBUFFER_COMPLETE || |
| 2922 IsContextLost()); | 2932 IsContextLost()); |
| 2923 | |
| 2924 InitializeViewport( | |
| 2925 frame, target_rect, gfx::Rect(target_rect.size()), target_rect.size()); | |
| 2926 return true; | 2933 return true; |
| 2927 } | 2934 } |
| 2928 | 2935 |
| 2929 void GLRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) { | 2936 void GLRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) { |
| 2930 EnsureScissorTestEnabled(); | 2937 EnsureScissorTestEnabled(); |
| 2931 | 2938 |
| 2932 // Don't unnecessarily ask the context to change the scissor, because it | 2939 // Don't unnecessarily ask the context to change the scissor, because it |
| 2933 // may cause undesired GPU pipeline flushes. | 2940 // may cause undesired GPU pipeline flushes. |
| 2934 if (scissor_rect == scissor_rect_ && !scissor_rect_needs_reset_) | 2941 if (scissor_rect == scissor_rect_ && !scissor_rect_needs_reset_) |
| 2935 return; | 2942 return; |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3522 context_support_->ScheduleOverlayPlane( | 3529 context_support_->ScheduleOverlayPlane( |
| 3523 overlay.plane_z_order, | 3530 overlay.plane_z_order, |
| 3524 overlay.transform, | 3531 overlay.transform, |
| 3525 pending_overlay_resources_.back()->texture_id(), | 3532 pending_overlay_resources_.back()->texture_id(), |
| 3526 overlay.display_rect, | 3533 overlay.display_rect, |
| 3527 overlay.uv_rect); | 3534 overlay.uv_rect); |
| 3528 } | 3535 } |
| 3529 } | 3536 } |
| 3530 | 3537 |
| 3531 } // namespace cc | 3538 } // namespace cc |
| OLD | NEW |