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

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

Issue 2252163003: Update Context Client Visibility to use Scoped Pattern (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix webview 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 29 matching lines...) Expand all
40 #include "cc/output/texture_mailbox_deleter.h" 40 #include "cc/output/texture_mailbox_deleter.h"
41 #include "cc/quads/draw_polygon.h" 41 #include "cc/quads/draw_polygon.h"
42 #include "cc/quads/picture_draw_quad.h" 42 #include "cc/quads/picture_draw_quad.h"
43 #include "cc/quads/render_pass.h" 43 #include "cc/quads/render_pass.h"
44 #include "cc/quads/stream_video_draw_quad.h" 44 #include "cc/quads/stream_video_draw_quad.h"
45 #include "cc/quads/texture_draw_quad.h" 45 #include "cc/quads/texture_draw_quad.h"
46 #include "cc/raster/scoped_gpu_raster.h" 46 #include "cc/raster/scoped_gpu_raster.h"
47 #include "cc/resources/resource_pool.h" 47 #include "cc/resources/resource_pool.h"
48 #include "cc/resources/scoped_resource.h" 48 #include "cc/resources/scoped_resource.h"
49 #include "gpu/GLES2/gl2extchromium.h" 49 #include "gpu/GLES2/gl2extchromium.h"
50 #include "gpu/command_buffer/client/context_support.h"
51 #include "gpu/command_buffer/client/gles2_interface.h" 50 #include "gpu/command_buffer/client/gles2_interface.h"
52 #include "gpu/command_buffer/common/gpu_memory_allocation.h" 51 #include "gpu/command_buffer/common/gpu_memory_allocation.h"
53 #include "media/base/media_switches.h" 52 #include "media/base/media_switches.h"
54 #include "skia/ext/texture_handle.h" 53 #include "skia/ext/texture_handle.h"
55 #include "third_party/skia/include/core/SkBitmap.h" 54 #include "third_party/skia/include/core/SkBitmap.h"
56 #include "third_party/skia/include/core/SkColor.h" 55 #include "third_party/skia/include/core/SkColor.h"
57 #include "third_party/skia/include/core/SkColorFilter.h" 56 #include "third_party/skia/include/core/SkColorFilter.h"
58 #include "third_party/skia/include/core/SkImage.h" 57 #include "third_party/skia/include/core/SkImage.h"
59 #include "third_party/skia/include/core/SkSurface.h" 58 #include "third_party/skia/include/core/SkSurface.h"
60 #include "third_party/skia/include/gpu/GrContext.h" 59 #include "third_party/skia/include/gpu/GrContext.h"
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 409 }
411 410
412 GLRenderer::~GLRenderer() { 411 GLRenderer::~GLRenderer() {
413 while (!pending_async_read_pixels_.empty()) { 412 while (!pending_async_read_pixels_.empty()) {
414 PendingAsyncReadPixels* pending_read = 413 PendingAsyncReadPixels* pending_read =
415 pending_async_read_pixels_.back().get(); 414 pending_async_read_pixels_.back().get();
416 pending_read->finished_read_pixels_callback.Cancel(); 415 pending_read->finished_read_pixels_callback.Cancel();
417 pending_async_read_pixels_.pop_back(); 416 pending_async_read_pixels_.pop_back();
418 } 417 }
419 418
419 // Set our visibility to false to ensure we clean up context resources.
420 UpdateVisibilityForContextProvider(false);
421
420 CleanupSharedObjects(); 422 CleanupSharedObjects();
421 } 423 }
422 424
423 const RendererCapabilitiesImpl& GLRenderer::Capabilities() const { 425 const RendererCapabilitiesImpl& GLRenderer::Capabilities() const {
424 return capabilities_; 426 return capabilities_;
425 } 427 }
426 428
427 bool GLRenderer::CanPartialSwap() { 429 bool GLRenderer::CanPartialSwap() {
428 auto* context_provider = output_surface_->context_provider(); 430 auto* context_provider = output_surface_->context_provider();
429 return context_provider->ContextCapabilities().post_sub_buffer; 431 return context_provider->ContextCapabilities().post_sub_buffer;
430 } 432 }
431 433
432 void GLRenderer::DidChangeVisibility() { 434 void GLRenderer::DidChangeVisibility() {
433 if (visible_) { 435 if (visible_) {
434 output_surface_->EnsureBackbuffer(); 436 output_surface_->EnsureBackbuffer();
435 } else { 437 } else {
436 TRACE_EVENT0("cc", "GLRenderer::DidChangeVisibility dropping resources"); 438 TRACE_EVENT0("cc", "GLRenderer::DidChangeVisibility dropping resources");
437 ReleaseRenderPassTextures(); 439 ReleaseRenderPassTextures();
438 output_surface_->DiscardBackbuffer(); 440 output_surface_->DiscardBackbuffer();
439 } 441 }
440 442
441 PrepareGeometry(NO_BINDING); 443 PrepareGeometry(NO_BINDING);
442 444
443 // Handle cleanup of resources on the ContextProvider. The compositor 445 UpdateVisibilityForContextProvider(visible_);
444 // ContextProvider is not shared, so always pass 0 for the client_id.
445 // TODO(crbug.com/487471): Update this when we share compositor
446 // ContextProviders.
447 context_support_->SetClientVisible(0 /* client_id */, visible_);
448 bool aggressively_free_resources = !context_support_->AnyClientsVisible();
449 if (aggressively_free_resources)
450 output_surface_->context_provider()->DeleteCachedResources();
451 context_support_->SetAggressivelyFreeResources(aggressively_free_resources);
452 } 446 }
453 447
454 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } 448 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); }
455 449
456 void GLRenderer::DiscardPixels() { 450 void GLRenderer::DiscardPixels() {
457 if (!use_discard_framebuffer_) 451 if (!use_discard_framebuffer_)
458 return; 452 return;
459 bool using_default_framebuffer = 453 bool using_default_framebuffer =
460 !current_framebuffer_lock_ && 454 !current_framebuffer_lock_ &&
461 output_surface_->capabilities().uses_default_gl_framebuffer; 455 output_surface_->capabilities().uses_default_gl_framebuffer;
(...skipping 3567 matching lines...) Expand 10 before | Expand all | Expand 10 after
4029 unsigned filter = ca_layer_overlay->filter; 4023 unsigned filter = ca_layer_overlay->filter;
4030 4024
4031 gl_->ScheduleCALayerSharedStateCHROMIUM( 4025 gl_->ScheduleCALayerSharedStateCHROMIUM(
4032 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, 4026 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect,
4033 sorting_context_id, gl_transform); 4027 sorting_context_id, gl_transform);
4034 gl_->ScheduleCALayerCHROMIUM( 4028 gl_->ScheduleCALayerCHROMIUM(
4035 texture_id, contents_rect, ca_layer_overlay->background_color, 4029 texture_id, contents_rect, ca_layer_overlay->background_color,
4036 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); 4030 ca_layer_overlay->edge_aa_mask, bounds_rect, filter);
4037 } 4031 }
4038 4032
4033 void GLRenderer::UpdateVisibilityForContextProvider(bool is_visible) {
4034 if (is_visible == !!context_client_visibility_)
4035 return;
4036
4037 if (is_visible) {
4038 context_client_visibility_ = context_support_->ClientBecameVisible();
4039 } else {
4040 context_support_->ClientBecameNotVisible(
4041 std::move(context_client_visibility_));
4042 }
4043
4044 if (!context_support_->AnyClientsVisible())
4045 output_surface_->context_provider()->DeleteCachedResources();
4046 }
4047
4039 } // namespace cc 4048 } // 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