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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 | 411 |
| 412 GLRenderer::~GLRenderer() { | 412 GLRenderer::~GLRenderer() { |
| 413 while (!pending_async_read_pixels_.empty()) { | 413 while (!pending_async_read_pixels_.empty()) { |
| 414 PendingAsyncReadPixels* pending_read = | 414 PendingAsyncReadPixels* pending_read = |
| 415 pending_async_read_pixels_.back().get(); | 415 pending_async_read_pixels_.back().get(); |
| 416 pending_read->finished_read_pixels_callback.Cancel(); | 416 pending_read->finished_read_pixels_callback.Cancel(); |
| 417 pending_async_read_pixels_.pop_back(); | 417 pending_async_read_pixels_.pop_back(); |
| 418 } | 418 } |
| 419 | 419 |
| 420 CleanupSharedObjects(); | 420 CleanupSharedObjects(); |
| 421 | |
| 422 if (context_visibility_) { | |
| 423 output_surface_->context_provider() | |
|
danakj
2016/08/26 23:49:08
nit: maybe
auto* cache_controller = outsur->conpr
ericrk
2016/08/29 22:43:22
Sadly, that first line is more than 80 chars... bu
danakj
2016/08/29 23:56:20
Eh, 3 lines for 3 lines with more text I guess.
| |
| 424 ->CacheController() | |
| 425 ->ClientBecameNotVisible(std::move(context_visibility_)); | |
| 426 } | |
| 421 } | 427 } |
| 422 | 428 |
| 423 const RendererCapabilitiesImpl& GLRenderer::Capabilities() const { | 429 const RendererCapabilitiesImpl& GLRenderer::Capabilities() const { |
| 424 return capabilities_; | 430 return capabilities_; |
| 425 } | 431 } |
| 426 | 432 |
| 427 bool GLRenderer::CanPartialSwap() { | 433 bool GLRenderer::CanPartialSwap() { |
| 428 auto* context_provider = output_surface_->context_provider(); | 434 auto* context_provider = output_surface_->context_provider(); |
| 429 return context_provider->ContextCapabilities().post_sub_buffer; | 435 return context_provider->ContextCapabilities().post_sub_buffer; |
| 430 } | 436 } |
| 431 | 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); |
| 442 | 448 |
| 443 // Handle cleanup of resources on the ContextProvider. The compositor | 449 if (visible_ && !context_visibility_) { |
|
danakj
2016/08/26 23:49:08
Can you actually become visible and have a context
ericrk
2016/08/29 22:43:22
Yeah, this seems reasonable.
| |
| 444 // ContextProvider is not shared, so always pass 0 for the client_id. | 450 context_visibility_ = output_surface_->context_provider() |
|
danakj
2016/08/26 23:49:08
similars for formatting?
ericrk
2016/08/29 22:43:22
Refactored.
| |
| 445 // TODO(crbug.com/487471): Update this when we share compositor | 451 ->CacheController() |
| 446 // ContextProviders. | 452 ->ClientBecameVisible(); |
| 447 context_support_->SetClientVisible(0 /* client_id */, visible_); | 453 } else if (!visible_ && context_visibility_) { |
| 448 bool aggressively_free_resources = !context_support_->AnyClientsVisible(); | 454 output_surface_->context_provider() |
| 449 if (aggressively_free_resources) | 455 ->CacheController() |
| 450 output_surface_->context_provider()->DeleteCachedResources(); | 456 ->ClientBecameNotVisible(std::move(context_visibility_)); |
| 451 context_support_->SetAggressivelyFreeResources(aggressively_free_resources); | 457 } |
| 452 } | 458 } |
| 453 | 459 |
| 454 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } | 460 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } |
| 455 | 461 |
| 456 void GLRenderer::DiscardPixels() { | 462 void GLRenderer::DiscardPixels() { |
| 457 if (!use_discard_framebuffer_) | 463 if (!use_discard_framebuffer_) |
| 458 return; | 464 return; |
| 459 bool using_default_framebuffer = | 465 bool using_default_framebuffer = |
| 460 !current_framebuffer_lock_ && | 466 !current_framebuffer_lock_ && |
| 461 output_surface_->capabilities().uses_default_gl_framebuffer; | 467 output_surface_->capabilities().uses_default_gl_framebuffer; |
| (...skipping 3571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4033 | 4039 |
| 4034 gl_->ScheduleCALayerSharedStateCHROMIUM( | 4040 gl_->ScheduleCALayerSharedStateCHROMIUM( |
| 4035 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, | 4041 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, |
| 4036 sorting_context_id, gl_transform); | 4042 sorting_context_id, gl_transform); |
| 4037 gl_->ScheduleCALayerCHROMIUM( | 4043 gl_->ScheduleCALayerCHROMIUM( |
| 4038 texture_id, contents_rect, ca_layer_overlay->background_color, | 4044 texture_id, contents_rect, ca_layer_overlay->background_color, |
| 4039 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); | 4045 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); |
| 4040 } | 4046 } |
| 4041 | 4047 |
| 4042 } // namespace cc | 4048 } // namespace cc |
| OLD | NEW |