Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: cc/output/gl_renderer.cc

Issue 2278283003: Refactor client visibility handling (Closed)
Patch Set: more fixes Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 408
409 GLRenderer::~GLRenderer() { 409 GLRenderer::~GLRenderer() {
410 while (!pending_async_read_pixels_.empty()) { 410 while (!pending_async_read_pixels_.empty()) {
411 PendingAsyncReadPixels* pending_read = 411 PendingAsyncReadPixels* pending_read =
412 pending_async_read_pixels_.back().get(); 412 pending_async_read_pixels_.back().get();
413 pending_read->finished_read_pixels_callback.Cancel(); 413 pending_read->finished_read_pixels_callback.Cancel();
414 pending_async_read_pixels_.pop_back(); 414 pending_async_read_pixels_.pop_back();
415 } 415 }
416 416
417 CleanupSharedObjects(); 417 CleanupSharedObjects();
418
419 if (context_visibility_) {
420 auto* context_provider = output_surface_->context_provider();
421 auto* cache_controller = context_provider->CacheController();
422 cache_controller->ClientBecameNotVisible(std::move(context_visibility_));
423 }
418 } 424 }
419 425
420 bool GLRenderer::CanPartialSwap() { 426 bool GLRenderer::CanPartialSwap() {
421 auto* context_provider = output_surface_->context_provider(); 427 auto* context_provider = output_surface_->context_provider();
422 return context_provider->ContextCapabilities().post_sub_buffer; 428 return context_provider->ContextCapabilities().post_sub_buffer;
423 } 429 }
424 430
425 void GLRenderer::DidChangeVisibility() { 431 void GLRenderer::DidChangeVisibility() {
426 if (visible_) { 432 if (visible_) {
427 output_surface_->EnsureBackbuffer(); 433 output_surface_->EnsureBackbuffer();
428 } else { 434 } else {
429 TRACE_EVENT0("cc", "GLRenderer::DidChangeVisibility dropping resources"); 435 TRACE_EVENT0("cc", "GLRenderer::DidChangeVisibility dropping resources");
430 ReleaseRenderPassTextures(); 436 ReleaseRenderPassTextures();
431 output_surface_->DiscardBackbuffer(); 437 output_surface_->DiscardBackbuffer();
432 } 438 }
433 439
434 PrepareGeometry(NO_BINDING); 440 PrepareGeometry(NO_BINDING);
435 441
436 // Handle cleanup of resources on the ContextProvider. The compositor 442 auto* context_provider = output_surface_->context_provider();
437 // ContextProvider is not shared, so always pass 0 for the client_id. 443 auto* cache_controller = context_provider->CacheController();
438 // TODO(crbug.com/487471): Update this when we share compositor 444 if (visible_) {
439 // ContextProviders. 445 DCHECK(!context_visibility_);
440 context_support_->SetClientVisible(0 /* client_id */, visible_); 446 context_visibility_ = cache_controller->ClientBecameVisible();
441 bool aggressively_free_resources = !context_support_->AnyClientsVisible(); 447 } else {
442 if (aggressively_free_resources) 448 DCHECK(context_visibility_);
443 output_surface_->context_provider()->DeleteCachedResources(); 449 cache_controller->ClientBecameNotVisible(std::move(context_visibility_));
444 context_support_->SetAggressivelyFreeResources(aggressively_free_resources); 450 }
445 } 451 }
446 452
447 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } 453 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); }
448 454
449 void GLRenderer::DiscardPixels() { 455 void GLRenderer::DiscardPixels() {
450 if (!use_discard_framebuffer_) 456 if (!use_discard_framebuffer_)
451 return; 457 return;
452 bool using_default_framebuffer = 458 bool using_default_framebuffer =
453 !current_framebuffer_lock_ && 459 !current_framebuffer_lock_ &&
454 output_surface_->capabilities().uses_default_gl_framebuffer; 460 output_surface_->capabilities().uses_default_gl_framebuffer;
(...skipping 3575 matching lines...) Expand 10 before | Expand all | Expand 10 after
4030 4036
4031 gl_->ScheduleCALayerSharedStateCHROMIUM( 4037 gl_->ScheduleCALayerSharedStateCHROMIUM(
4032 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, 4038 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect,
4033 sorting_context_id, gl_transform); 4039 sorting_context_id, gl_transform);
4034 gl_->ScheduleCALayerCHROMIUM( 4040 gl_->ScheduleCALayerCHROMIUM(
4035 texture_id, contents_rect, ca_layer_overlay->background_color, 4041 texture_id, contents_rect, ca_layer_overlay->background_color,
4036 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); 4042 ca_layer_overlay->edge_aa_mask, bounds_rect, filter);
4037 } 4043 }
4038 4044
4039 } // namespace cc 4045 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698