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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 const auto& context_caps = | 395 const auto& context_caps = |
396 output_surface_->context_provider()->ContextCapabilities(); | 396 output_surface_->context_provider()->ContextCapabilities(); |
397 DCHECK(!context_caps.iosurface || context_caps.texture_rectangle); | 397 DCHECK(!context_caps.iosurface || context_caps.texture_rectangle); |
398 | 398 |
399 use_discard_framebuffer_ = context_caps.discard_framebuffer; | 399 use_discard_framebuffer_ = context_caps.discard_framebuffer; |
400 use_sync_query_ = context_caps.sync_query; | 400 use_sync_query_ = context_caps.sync_query; |
401 use_blend_equation_advanced_ = context_caps.blend_equation_advanced; | 401 use_blend_equation_advanced_ = context_caps.blend_equation_advanced; |
402 use_blend_equation_advanced_coherent_ = | 402 use_blend_equation_advanced_coherent_ = |
403 context_caps.blend_equation_advanced_coherent; | 403 context_caps.blend_equation_advanced_coherent; |
404 use_occlusion_query_ = context_caps.occlusion_query; | 404 use_occlusion_query_ = context_caps.occlusion_query; |
| 405 use_swap_with_bounds_ = context_caps.swap_buffers_with_bounds; |
405 | 406 |
406 InitializeSharedObjects(); | 407 InitializeSharedObjects(); |
407 } | 408 } |
408 | 409 |
409 GLRenderer::~GLRenderer() { | 410 GLRenderer::~GLRenderer() { |
410 CleanupSharedObjects(); | 411 CleanupSharedObjects(); |
411 | 412 |
412 if (context_visibility_) { | 413 if (context_visibility_) { |
413 auto* context_provider = output_surface_->context_provider(); | 414 auto* context_provider = output_surface_->context_provider(); |
414 auto* cache_controller = context_provider->CacheController(); | 415 auto* cache_controller = context_provider->CacheController(); |
415 cache_controller->ClientBecameNotVisible(std::move(context_visibility_)); | 416 cache_controller->ClientBecameNotVisible(std::move(context_visibility_)); |
416 } | 417 } |
417 } | 418 } |
418 | 419 |
419 bool GLRenderer::CanPartialSwap() { | 420 bool GLRenderer::CanPartialSwap() { |
| 421 if (use_swap_with_bounds_) |
| 422 return false; |
420 auto* context_provider = output_surface_->context_provider(); | 423 auto* context_provider = output_surface_->context_provider(); |
421 return context_provider->ContextCapabilities().post_sub_buffer; | 424 return context_provider->ContextCapabilities().post_sub_buffer; |
422 } | 425 } |
423 | 426 |
424 ResourceFormat GLRenderer::BackbufferFormat() const { | 427 ResourceFormat GLRenderer::BackbufferFormat() const { |
425 // TODO(ccameron): If we are targeting high bit depth or HDR, we should use | 428 // TODO(ccameron): If we are targeting high bit depth or HDR, we should use |
426 // RGBA_F16 here. | 429 // RGBA_F16 here. |
427 return resource_provider_->best_texture_format(); | 430 return resource_provider_->best_texture_format(); |
428 } | 431 } |
429 | 432 |
(...skipping 2154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2584 DCHECK(visible_); | 2587 DCHECK(visible_); |
2585 | 2588 |
2586 TRACE_EVENT0("cc", "GLRenderer::SwapBuffers"); | 2589 TRACE_EVENT0("cc", "GLRenderer::SwapBuffers"); |
2587 // We're done! Time to swapbuffers! | 2590 // We're done! Time to swapbuffers! |
2588 | 2591 |
2589 gfx::Size surface_size = surface_size_for_swap_buffers(); | 2592 gfx::Size surface_size = surface_size_for_swap_buffers(); |
2590 | 2593 |
2591 OutputSurfaceFrame output_frame; | 2594 OutputSurfaceFrame output_frame; |
2592 output_frame.latency_info = std::move(latency_info); | 2595 output_frame.latency_info = std::move(latency_info); |
2593 output_frame.size = surface_size; | 2596 output_frame.size = surface_size; |
2594 if (use_partial_swap_) { | 2597 if (use_swap_with_bounds_) { |
| 2598 output_frame.content_bounds = current_frame()->root_content_bounds; |
| 2599 } else if (use_partial_swap_) { |
2595 // If supported, we can save significant bandwidth by only swapping the | 2600 // If supported, we can save significant bandwidth by only swapping the |
2596 // damaged/scissored region (clamped to the viewport). | 2601 // damaged/scissored region (clamped to the viewport). |
2597 swap_buffer_rect_.Intersect(gfx::Rect(surface_size)); | 2602 swap_buffer_rect_.Intersect(gfx::Rect(surface_size)); |
2598 int flipped_y_pos_of_rect_bottom = surface_size.height() - | 2603 int flipped_y_pos_of_rect_bottom = surface_size.height() - |
2599 swap_buffer_rect_.y() - | 2604 swap_buffer_rect_.y() - |
2600 swap_buffer_rect_.height(); | 2605 swap_buffer_rect_.height(); |
2601 output_frame.sub_buffer_rect = | 2606 output_frame.sub_buffer_rect = |
2602 gfx::Rect(swap_buffer_rect_.x(), | 2607 gfx::Rect(swap_buffer_rect_.x(), |
2603 FlippedRootFramebuffer() ? flipped_y_pos_of_rect_bottom | 2608 FlippedRootFramebuffer() ? flipped_y_pos_of_rect_bottom |
2604 : swap_buffer_rect_.y(), | 2609 : swap_buffer_rect_.y(), |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3493 return; | 3498 return; |
3494 | 3499 |
3495 // Report GPU overdraw as a percentage of |max_result|. | 3500 // Report GPU overdraw as a percentage of |max_result|. |
3496 TRACE_COUNTER1( | 3501 TRACE_COUNTER1( |
3497 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", | 3502 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", |
3498 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / | 3503 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / |
3499 max_result); | 3504 max_result); |
3500 } | 3505 } |
3501 | 3506 |
3502 } // namespace cc | 3507 } // namespace cc |
OLD | NEW |