| 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 auto* cache_controller = context_provider->CacheController(); | 422 auto* cache_controller = context_provider->CacheController(); |
| 423 cache_controller->ClientBecameNotVisible(std::move(context_visibility_)); | 423 cache_controller->ClientBecameNotVisible(std::move(context_visibility_)); |
| 424 } | 424 } |
| 425 } | 425 } |
| 426 | 426 |
| 427 bool GLRenderer::CanPartialSwap() { | 427 bool GLRenderer::CanPartialSwap() { |
| 428 auto* context_provider = output_surface_->context_provider(); | 428 auto* context_provider = output_surface_->context_provider(); |
| 429 return context_provider->ContextCapabilities().post_sub_buffer; | 429 return context_provider->ContextCapabilities().post_sub_buffer; |
| 430 } | 430 } |
| 431 | 431 |
| 432 ResourceFormat GLRenderer::BackbufferFormat() const { | |
| 433 // TODO(ccameron): If we are targeting high bit depth or HDR, we should use | |
| 434 // RGBA_F16 here. | |
| 435 return resource_provider_->best_texture_format(); | |
| 436 } | |
| 437 | |
| 438 void GLRenderer::DidChangeVisibility() { | 432 void GLRenderer::DidChangeVisibility() { |
| 439 if (visible_) { | 433 if (visible_) { |
| 440 output_surface_->EnsureBackbuffer(); | 434 output_surface_->EnsureBackbuffer(); |
| 441 } else { | 435 } else { |
| 442 TRACE_EVENT0("cc", "GLRenderer::DidChangeVisibility dropping resources"); | 436 TRACE_EVENT0("cc", "GLRenderer::DidChangeVisibility dropping resources"); |
| 443 ReleaseRenderPassTextures(); | 437 ReleaseRenderPassTextures(); |
| 444 output_surface_->DiscardBackbuffer(); | 438 output_surface_->DiscardBackbuffer(); |
| 445 } | 439 } |
| 446 | 440 |
| 447 PrepareGeometry(NO_BINDING); | 441 PrepareGeometry(NO_BINDING); |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 } | 900 } |
| 907 | 901 |
| 908 std::unique_ptr<ScopedResource> GLRenderer::GetBackdropTexture( | 902 std::unique_ptr<ScopedResource> GLRenderer::GetBackdropTexture( |
| 909 DrawingFrame* frame, | 903 DrawingFrame* frame, |
| 910 const gfx::Rect& bounding_rect) { | 904 const gfx::Rect& bounding_rect) { |
| 911 std::unique_ptr<ScopedResource> device_background_texture = | 905 std::unique_ptr<ScopedResource> device_background_texture = |
| 912 ScopedResource::Create(resource_provider_); | 906 ScopedResource::Create(resource_provider_); |
| 913 // CopyTexImage2D fails when called on a texture having immutable storage. | 907 // CopyTexImage2D fails when called on a texture having immutable storage. |
| 914 device_background_texture->Allocate( | 908 device_background_texture->Allocate( |
| 915 bounding_rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, | 909 bounding_rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, |
| 916 BackbufferFormat(), frame->device_color_space); | 910 resource_provider_->best_texture_format(), frame->device_color_space); |
| 917 { | 911 { |
| 918 ResourceProvider::ScopedWriteLockGL lock( | 912 ResourceProvider::ScopedWriteLockGL lock( |
| 919 resource_provider_, device_background_texture->id(), false); | 913 resource_provider_, device_background_texture->id(), false); |
| 920 GetFramebufferTexture(lock.texture_id(), bounding_rect); | 914 GetFramebufferTexture(lock.texture_id(), bounding_rect); |
| 921 } | 915 } |
| 922 return device_background_texture; | 916 return device_background_texture; |
| 923 } | 917 } |
| 924 | 918 |
| 925 sk_sp<SkImage> GLRenderer::ApplyBackgroundFilters( | 919 sk_sp<SkImage> GLRenderer::ApplyBackgroundFilters( |
| 926 const RenderPassDrawQuad* quad, | 920 const RenderPassDrawQuad* quad, |
| (...skipping 2750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3677 return; | 3671 return; |
| 3678 | 3672 |
| 3679 // Report GPU overdraw as a percentage of |max_result|. | 3673 // Report GPU overdraw as a percentage of |max_result|. |
| 3680 TRACE_COUNTER1( | 3674 TRACE_COUNTER1( |
| 3681 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", | 3675 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", |
| 3682 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / | 3676 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / |
| 3683 max_result); | 3677 max_result); |
| 3684 } | 3678 } |
| 3685 | 3679 |
| 3686 } // namespace cc | 3680 } // namespace cc |
| OLD | NEW |