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

Unified Diff: content/browser/android/in_process/synchronous_compositor_output_surface.cc

Issue 1164083003: Free context resources when memory limit is 0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: visible as well Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/android/in_process/synchronous_compositor_output_surface.cc
diff --git a/content/browser/android/in_process/synchronous_compositor_output_surface.cc b/content/browser/android/in_process/synchronous_compositor_output_surface.cc
index 1e61994e2d00bab2b9cfb4f1bcd94f7f67fd7bbb..95d82804247a41976c30ad13917e8febc90aafab 100644
--- a/content/browser/android/in_process/synchronous_compositor_output_surface.cc
+++ b/content/browser/android/in_process/synchronous_compositor_output_surface.cc
@@ -16,6 +16,7 @@
#include "content/browser/gpu/compositor_util.h"
#include "content/public/browser/browser_thread.h"
#include "content/renderer/gpu/frame_swap_message_queue.h"
+#include "gpu/command_buffer/client/context_support.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/common/gpu_memory_allocation.h"
#include "third_party/skia/include/core/SkCanvas.h"
@@ -243,11 +244,22 @@ void SynchronousCompositorOutputSurface::ReturnResources(
void SynchronousCompositorOutputSurface::SetMemoryPolicy(size_t bytes_limit) {
DCHECK(CalledOnValidThread());
+ bool became_zero = memory_policy_.bytes_limit_when_visible && !bytes_limit;
+ bool became_non_zero =
+ !memory_policy_.bytes_limit_when_visible && bytes_limit;
memory_policy_.bytes_limit_when_visible = bytes_limit;
memory_policy_.num_resources_limit = kNumResourcesLimit;
if (client_)
client_->SetMemoryPolicy(memory_policy_);
+
+ if (became_zero) {
+ // This is small hack to drop context resources without destroying it
+ // when this compositor is put into the background.
+ context_provider()->ContextSupport()->SetSurfaceVisible(false);
+ } else if (became_non_zero) {
+ context_provider()->ContextSupport()->SetSurfaceVisible(true);
+ }
}
void SynchronousCompositorOutputSurface::SetTreeActivationCallback(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698