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 |
432 void GLRenderer::DidChangeVisibility() { | 438 void GLRenderer::DidChangeVisibility() { |
433 if (visible_) { | 439 if (visible_) { |
434 output_surface_->EnsureBackbuffer(); | 440 output_surface_->EnsureBackbuffer(); |
435 } else { | 441 } else { |
436 TRACE_EVENT0("cc", "GLRenderer::DidChangeVisibility dropping resources"); | 442 TRACE_EVENT0("cc", "GLRenderer::DidChangeVisibility dropping resources"); |
437 ReleaseRenderPassTextures(); | 443 ReleaseRenderPassTextures(); |
438 output_surface_->DiscardBackbuffer(); | 444 output_surface_->DiscardBackbuffer(); |
439 } | 445 } |
440 | 446 |
441 PrepareGeometry(NO_BINDING); | 447 PrepareGeometry(NO_BINDING); |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 } | 906 } |
901 | 907 |
902 std::unique_ptr<ScopedResource> GLRenderer::GetBackdropTexture( | 908 std::unique_ptr<ScopedResource> GLRenderer::GetBackdropTexture( |
903 DrawingFrame* frame, | 909 DrawingFrame* frame, |
904 const gfx::Rect& bounding_rect) { | 910 const gfx::Rect& bounding_rect) { |
905 std::unique_ptr<ScopedResource> device_background_texture = | 911 std::unique_ptr<ScopedResource> device_background_texture = |
906 ScopedResource::Create(resource_provider_); | 912 ScopedResource::Create(resource_provider_); |
907 // CopyTexImage2D fails when called on a texture having immutable storage. | 913 // CopyTexImage2D fails when called on a texture having immutable storage. |
908 device_background_texture->Allocate( | 914 device_background_texture->Allocate( |
909 bounding_rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, | 915 bounding_rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, |
910 resource_provider_->best_texture_format(), frame->device_color_space); | 916 BackbufferFormat(), frame->device_color_space); |
911 { | 917 { |
912 ResourceProvider::ScopedWriteLockGL lock( | 918 ResourceProvider::ScopedWriteLockGL lock( |
913 resource_provider_, device_background_texture->id(), false); | 919 resource_provider_, device_background_texture->id(), false); |
914 GetFramebufferTexture(lock.texture_id(), bounding_rect); | 920 GetFramebufferTexture(lock.texture_id(), bounding_rect); |
915 } | 921 } |
916 return device_background_texture; | 922 return device_background_texture; |
917 } | 923 } |
918 | 924 |
919 sk_sp<SkImage> GLRenderer::ApplyBackgroundFilters( | 925 sk_sp<SkImage> GLRenderer::ApplyBackgroundFilters( |
920 const RenderPassDrawQuad* quad, | 926 const RenderPassDrawQuad* quad, |
(...skipping 2661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3582 return; | 3588 return; |
3583 | 3589 |
3584 // Report GPU overdraw as a percentage of |max_result|. | 3590 // Report GPU overdraw as a percentage of |max_result|. |
3585 TRACE_COUNTER1( | 3591 TRACE_COUNTER1( |
3586 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", | 3592 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", |
3587 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / | 3593 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / |
3588 max_result); | 3594 max_result); |
3589 } | 3595 } |
3590 | 3596 |
3591 } // namespace cc | 3597 } // namespace cc |
OLD | NEW |