diff options
author | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-30 20:38:36 +0000 |
---|---|---|
committer | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-30 20:38:36 +0000 |
commit | 2e0975dcc32fcac823d35e42514169e41a3a7fd3 (patch) | |
tree | b010300f234789716d26be9fd6b2b0348d999e4a /webkit/common | |
parent | 6734e40aa3d7fc25ec790b9148ac61f8c4607a55 (diff) | |
download | chromium_src-2e0975dcc32fcac823d35e42514169e41a3a7fd3.zip chromium_src-2e0975dcc32fcac823d35e42514169e41a3a7fd3.tar.gz chromium_src-2e0975dcc32fcac823d35e42514169e41a3a7fd3.tar.bz2 |
cc: Delete GrContext resources when tab becomes invisible.
BUG=366519
Review URL: https://codereview.chromium.org/255593002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267324 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/common')
4 files changed, 21 insertions, 21 deletions
diff --git a/webkit/common/gpu/context_provider_in_process.cc b/webkit/common/gpu/context_provider_in_process.cc index d71d6fa..3785d38a 100644 --- a/webkit/common/gpu/context_provider_in_process.cc +++ b/webkit/common/gpu/context_provider_in_process.cc @@ -164,6 +164,13 @@ void ContextProviderInProcess::VerifyContexts() { OnLostContext(); } +void ContextProviderInProcess::DeleteCachedResources() { + DCHECK(context_thread_checker_.CalledOnValidThread()); + + if (gr_context_) + gr_context_->FreeGpuResources(); +} + void ContextProviderInProcess::OnLostContext() { DCHECK(context_thread_checker_.CalledOnValidThread()); { diff --git a/webkit/common/gpu/context_provider_in_process.h b/webkit/common/gpu/context_provider_in_process.h index c42585f..3df327b 100644 --- a/webkit/common/gpu/context_provider_in_process.h +++ b/webkit/common/gpu/context_provider_in_process.h @@ -39,6 +39,7 @@ class WEBKIT_GPU_EXPORT ContextProviderInProcess virtual class GrContext* GrContext() OVERRIDE; virtual bool IsContextLost() OVERRIDE; virtual void VerifyContexts() OVERRIDE; + virtual void DeleteCachedResources() OVERRIDE; virtual bool DestroyedOnMainThread() OVERRIDE; virtual void SetLostContextCallback( const LostContextCallback& lost_context_callback) OVERRIDE; diff --git a/webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc b/webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc index f612a14..5c7bc39 100644 --- a/webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc +++ b/webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc @@ -35,11 +35,17 @@ GrContextForWebGraphicsContext3D::GrContextForWebGraphicsContext3D( gr_context_ = skia::AdoptRef(GrContext::Create( kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get()))); - if (!gr_context_) - return; + if (gr_context_) { + // The limit of the number of textures we hold in the GrContext's + // bitmap->texture cache. + static const int kMaxGaneshTextureCacheCount = 2048; + // The limit of the bytes allocated toward textures in the GrContext's + // bitmap->texture cache. + static const size_t kMaxGaneshTextureCacheBytes = 96 * 1024 * 1024; - bool nonzero_allocation = true; - SetMemoryLimit(nonzero_allocation); + gr_context_->setTextureCacheLimits(kMaxGaneshTextureCacheCount, + kMaxGaneshTextureCacheBytes); + } } GrContextForWebGraphicsContext3D::~GrContextForWebGraphicsContext3D() { @@ -50,25 +56,11 @@ void GrContextForWebGraphicsContext3D::OnLostContext() { gr_context_->contextDestroyed(); } -void GrContextForWebGraphicsContext3D::SetMemoryLimit(bool nonzero_allocation) { - if (!gr_context_) - return; - - if (nonzero_allocation) { - // The limit of the number of textures we hold in the GrContext's - // bitmap->texture cache. - static const int kMaxGaneshTextureCacheCount = 2048; - // The limit of the bytes allocated toward textures in the GrContext's - // bitmap->texture cache. - static const size_t kMaxGaneshTextureCacheBytes = 96 * 1024 * 1024; - - gr_context_->setTextureCacheLimits( - kMaxGaneshTextureCacheCount, kMaxGaneshTextureCacheBytes); - } else { +void GrContextForWebGraphicsContext3D::FreeGpuResources() { + if (gr_context_) { TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", \ TRACE_EVENT_SCOPE_THREAD); gr_context_->freeGpuResources(); - gr_context_->setTextureCacheLimits(0, 0); } } diff --git a/webkit/common/gpu/grcontext_for_webgraphicscontext3d.h b/webkit/common/gpu/grcontext_for_webgraphicscontext3d.h index d018833..5c983aa 100644 --- a/webkit/common/gpu/grcontext_for_webgraphicscontext3d.h +++ b/webkit/common/gpu/grcontext_for_webgraphicscontext3d.h @@ -27,7 +27,7 @@ class WEBKIT_GPU_EXPORT GrContextForWebGraphicsContext3D { GrContext* get() { return gr_context_.get(); } void OnLostContext(); - void SetMemoryLimit(bool nonzero_allocation); + void FreeGpuResources(); private: skia::RefPtr<class GrContext> gr_context_; |