Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 const auto& context_caps = | 394 const auto& context_caps = |
| 395 output_surface_->context_provider()->ContextCapabilities(); | 395 output_surface_->context_provider()->ContextCapabilities(); |
| 396 DCHECK(!context_caps.iosurface || context_caps.texture_rectangle); | 396 DCHECK(!context_caps.iosurface || context_caps.texture_rectangle); |
| 397 | 397 |
| 398 use_discard_framebuffer_ = context_caps.discard_framebuffer; | 398 use_discard_framebuffer_ = context_caps.discard_framebuffer; |
| 399 use_sync_query_ = context_caps.sync_query; | 399 use_sync_query_ = context_caps.sync_query; |
| 400 use_blend_equation_advanced_ = context_caps.blend_equation_advanced; | 400 use_blend_equation_advanced_ = context_caps.blend_equation_advanced; |
| 401 use_blend_equation_advanced_coherent_ = | 401 use_blend_equation_advanced_coherent_ = |
| 402 context_caps.blend_equation_advanced_coherent; | 402 context_caps.blend_equation_advanced_coherent; |
| 403 use_occlusion_query_ = context_caps.occlusion_query; | 403 use_occlusion_query_ = context_caps.occlusion_query; |
| 404 use_swap_with_bounds_ = context_caps.swap_buffers_with_bounds; | |
| 404 | 405 |
| 405 InitializeSharedObjects(); | 406 InitializeSharedObjects(); |
| 406 } | 407 } |
| 407 | 408 |
| 408 GLRenderer::~GLRenderer() { | 409 GLRenderer::~GLRenderer() { |
| 409 CleanupSharedObjects(); | 410 CleanupSharedObjects(); |
| 410 | 411 |
| 411 if (context_visibility_) { | 412 if (context_visibility_) { |
| 412 auto* context_provider = output_surface_->context_provider(); | 413 auto* context_provider = output_surface_->context_provider(); |
| 413 auto* cache_controller = context_provider->CacheController(); | 414 auto* cache_controller = context_provider->CacheController(); |
| 414 cache_controller->ClientBecameNotVisible(std::move(context_visibility_)); | 415 cache_controller->ClientBecameNotVisible(std::move(context_visibility_)); |
| 415 } | 416 } |
| 416 } | 417 } |
| 417 | 418 |
| 418 bool GLRenderer::CanPartialSwap() { | 419 bool GLRenderer::CanPartialSwap() { |
| 419 auto* context_provider = output_surface_->context_provider(); | 420 auto* context_provider = output_surface_->context_provider(); |
| 420 return context_provider->ContextCapabilities().post_sub_buffer; | 421 return context_provider->ContextCapabilities().post_sub_buffer; |
|
danakj
2017/02/16 18:54:19
Should this be false if use_swap_with_bounds_? We'
halliwell
2017/02/23 18:01:46
It's true that a 3-state enum represents the state
danakj
2017/02/24 22:05:18
Ya, I think with the optional changes u did this i
| |
| 421 } | 422 } |
| 422 | 423 |
| 423 ResourceFormat GLRenderer::BackbufferFormat() const { | 424 ResourceFormat GLRenderer::BackbufferFormat() const { |
| 424 // TODO(ccameron): If we are targeting high bit depth or HDR, we should use | 425 // TODO(ccameron): If we are targeting high bit depth or HDR, we should use |
| 425 // RGBA_F16 here. | 426 // RGBA_F16 here. |
| 426 return resource_provider_->best_texture_format(); | 427 return resource_provider_->best_texture_format(); |
| 427 } | 428 } |
| 428 | 429 |
| 429 void GLRenderer::DidChangeVisibility() { | 430 void GLRenderer::DidChangeVisibility() { |
| 430 if (visible_) { | 431 if (visible_) { |
| (...skipping 2194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2625 DCHECK(visible_); | 2626 DCHECK(visible_); |
| 2626 | 2627 |
| 2627 TRACE_EVENT0("cc", "GLRenderer::SwapBuffers"); | 2628 TRACE_EVENT0("cc", "GLRenderer::SwapBuffers"); |
| 2628 // We're done! Time to swapbuffers! | 2629 // We're done! Time to swapbuffers! |
| 2629 | 2630 |
| 2630 gfx::Size surface_size = surface_size_for_swap_buffers(); | 2631 gfx::Size surface_size = surface_size_for_swap_buffers(); |
| 2631 | 2632 |
| 2632 OutputSurfaceFrame output_frame; | 2633 OutputSurfaceFrame output_frame; |
| 2633 output_frame.latency_info = std::move(latency_info); | 2634 output_frame.latency_info = std::move(latency_info); |
| 2634 output_frame.size = surface_size; | 2635 output_frame.size = surface_size; |
| 2635 if (use_partial_swap_) { | 2636 if (use_swap_with_bounds_) { |
| 2637 output_frame.content_bounds = current_frame()->root_content_bounds; | |
| 2638 swap_buffer_rect_ = gfx::Rect(surface_size); | |
|
danakj
2017/02/16 18:54:19
Do you intentionally overload not supporting empty
halliwell
2017/02/23 18:01:46
Correct. The case of allow_empty_swap_ when use_p
| |
| 2639 output_frame.sub_buffer_rect = swap_buffer_rect_; | |
| 2640 } else if (use_partial_swap_) { | |
| 2636 // If supported, we can save significant bandwidth by only swapping the | 2641 // If supported, we can save significant bandwidth by only swapping the |
| 2637 // damaged/scissored region (clamped to the viewport). | 2642 // damaged/scissored region (clamped to the viewport). |
| 2638 swap_buffer_rect_.Intersect(gfx::Rect(surface_size)); | 2643 swap_buffer_rect_.Intersect(gfx::Rect(surface_size)); |
| 2639 int flipped_y_pos_of_rect_bottom = surface_size.height() - | 2644 int flipped_y_pos_of_rect_bottom = surface_size.height() - |
| 2640 swap_buffer_rect_.y() - | 2645 swap_buffer_rect_.y() - |
| 2641 swap_buffer_rect_.height(); | 2646 swap_buffer_rect_.height(); |
| 2642 output_frame.sub_buffer_rect = | 2647 output_frame.sub_buffer_rect = |
| 2643 gfx::Rect(swap_buffer_rect_.x(), | 2648 gfx::Rect(swap_buffer_rect_.x(), |
| 2644 FlippedRootFramebuffer() ? flipped_y_pos_of_rect_bottom | 2649 FlippedRootFramebuffer() ? flipped_y_pos_of_rect_bottom |
| 2645 : swap_buffer_rect_.y(), | 2650 : swap_buffer_rect_.y(), |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3526 return; | 3531 return; |
| 3527 | 3532 |
| 3528 // Report GPU overdraw as a percentage of |max_result|. | 3533 // Report GPU overdraw as a percentage of |max_result|. |
| 3529 TRACE_COUNTER1( | 3534 TRACE_COUNTER1( |
| 3530 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", | 3535 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", |
| 3531 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / | 3536 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / |
| 3532 max_result); | 3537 max_result); |
| 3533 } | 3538 } |
| 3534 | 3539 |
| 3535 } // namespace cc | 3540 } // namespace cc |
| OLD | NEW |