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 if (output_surface_->IsHighBitDepth()) { |
| 434 if (resource_provider_->IsResourceFormatSupported(RGBA_F16)) |
| 435 return RGBA_F16; |
| 436 } |
| 437 return resource_provider_->best_texture_format(); |
| 438 } |
| 439 |
432 void GLRenderer::DidChangeVisibility() { | 440 void GLRenderer::DidChangeVisibility() { |
433 if (visible_) { | 441 if (visible_) { |
434 output_surface_->EnsureBackbuffer(); | 442 output_surface_->EnsureBackbuffer(); |
435 } else { | 443 } else { |
436 TRACE_EVENT0("cc", "GLRenderer::DidChangeVisibility dropping resources"); | 444 TRACE_EVENT0("cc", "GLRenderer::DidChangeVisibility dropping resources"); |
437 ReleaseRenderPassTextures(); | 445 ReleaseRenderPassTextures(); |
438 output_surface_->DiscardBackbuffer(); | 446 output_surface_->DiscardBackbuffer(); |
439 } | 447 } |
440 | 448 |
441 PrepareGeometry(NO_BINDING); | 449 PrepareGeometry(NO_BINDING); |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 } | 908 } |
901 | 909 |
902 std::unique_ptr<ScopedResource> GLRenderer::GetBackdropTexture( | 910 std::unique_ptr<ScopedResource> GLRenderer::GetBackdropTexture( |
903 DrawingFrame* frame, | 911 DrawingFrame* frame, |
904 const gfx::Rect& bounding_rect) { | 912 const gfx::Rect& bounding_rect) { |
905 std::unique_ptr<ScopedResource> device_background_texture = | 913 std::unique_ptr<ScopedResource> device_background_texture = |
906 ScopedResource::Create(resource_provider_); | 914 ScopedResource::Create(resource_provider_); |
907 // CopyTexImage2D fails when called on a texture having immutable storage. | 915 // CopyTexImage2D fails when called on a texture having immutable storage. |
908 device_background_texture->Allocate( | 916 device_background_texture->Allocate( |
909 bounding_rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, | 917 bounding_rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, |
910 resource_provider_->best_texture_format(), frame->device_color_space); | 918 BackbufferFormat(), frame->device_color_space); |
911 { | 919 { |
912 ResourceProvider::ScopedWriteLockGL lock( | 920 ResourceProvider::ScopedWriteLockGL lock( |
913 resource_provider_, device_background_texture->id(), false); | 921 resource_provider_, device_background_texture->id(), false); |
914 GetFramebufferTexture(lock.texture_id(), bounding_rect); | 922 GetFramebufferTexture(lock.texture_id(), bounding_rect); |
915 } | 923 } |
916 return device_background_texture; | 924 return device_background_texture; |
917 } | 925 } |
918 | 926 |
919 sk_sp<SkImage> GLRenderer::ApplyBackgroundFilters( | 927 sk_sp<SkImage> GLRenderer::ApplyBackgroundFilters( |
920 const RenderPassDrawQuad* quad, | 928 const RenderPassDrawQuad* quad, |
(...skipping 2676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3597 return; | 3605 return; |
3598 | 3606 |
3599 // Report GPU overdraw as a percentage of |max_result|. | 3607 // Report GPU overdraw as a percentage of |max_result|. |
3600 TRACE_COUNTER1( | 3608 TRACE_COUNTER1( |
3601 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", | 3609 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", |
3602 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / | 3610 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / |
3603 max_result); | 3611 max_result); |
3604 } | 3612 } |
3605 | 3613 |
3606 } // namespace cc | 3614 } // namespace cc |
OLD | NEW |