diff options
author | reveman <reveman@chromium.org> | 2015-08-18 10:18:51 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-18 17:19:36 +0000 |
commit | af0ab609b53c64ce43172be42e20e7ca8beab497 (patch) | |
tree | ed60dc919d12170d57e64d17a3d2f0471cd3dd15 /cc/output | |
parent | 4924118f2dd3246df9f45efd010b590bc8771f8d (diff) | |
download | chromium_src-af0ab609b53c64ce43172be42e20e7ca8beab497.zip chromium_src-af0ab609b53c64ce43172be42e20e7ca8beab497.tar.gz chromium_src-af0ab609b53c64ce43172be42e20e7ca8beab497.tar.bz2 |
Re-land: cc: Use worker context for one-copy tile initialization.
This moves management of staging resources to
OneCopyTileTaskWorkerPool class. This makes it possible
to use a worker context to issue and detect when copy
operations complete.
BUG=490295
TBR=jamesr@chromium.org, sky@chromium.org
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1230203007
Cr-Commit-Position: refs/heads/master@{#343947}
Diffstat (limited to 'cc/output')
-rw-r--r-- | cc/output/context_provider.h | 22 | ||||
-rw-r--r-- | cc/output/output_surface.cc | 21 |
2 files changed, 24 insertions, 19 deletions
diff --git a/cc/output/context_provider.h b/cc/output/context_provider.h index aa4367d..c024e02 100644 --- a/cc/output/context_provider.h +++ b/cc/output/context_provider.h @@ -7,6 +7,7 @@ #include "base/callback.h" #include "base/memory/ref_counted.h" +#include "base/synchronization/lock.h" #include "cc/base/cc_export.h" #include "gpu/command_buffer/common/capabilities.h" @@ -26,6 +27,27 @@ struct ManagedMemoryPolicy; class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> { public: + class ScopedContextLock { + public: + explicit ScopedContextLock(ContextProvider* context_provider) + : context_provider_(context_provider), + context_lock_(*context_provider_->GetLock()) { + // Allow current thread to bind to |context_provider|. + context_provider_->DetachFromThread(); + } + ~ScopedContextLock() { + // Allow a different thread to bind to |context_provider|. + context_provider_->DetachFromThread(); + } + + gpu::gles2::GLES2Interface* ContextGL() { + return context_provider_->ContextGL(); + } + + private: + ContextProvider* const context_provider_; + base::AutoLock context_lock_; + }; // Bind the 3d context to the current thread. This should be called before // accessing the contexts. Calling it more than once should have no effect. // Once this function has been called, the class should only be accessed diff --git a/cc/output/output_surface.cc b/cc/output/output_surface.cc index a597a87..0786d66 100644 --- a/cc/output/output_surface.cc +++ b/cc/output/output_surface.cc @@ -107,10 +107,6 @@ OutputSurface::~OutputSurface() { context_provider_->SetMemoryPolicyChangedCallback( ContextProvider::MemoryPolicyChangedCallback()); } - if (worker_context_provider_.get()) { - worker_context_provider_->SetLostContextCallback( - ContextProvider::LostContextCallback()); - } } bool OutputSurface::HasExternalStencilTest() const { @@ -134,14 +130,8 @@ bool OutputSurface::BindToClient(OutputSurfaceClient* client) { if (success && worker_context_provider_.get()) { success = worker_context_provider_->BindToCurrentThread(); - if (success) { + if (success) worker_context_provider_->SetupLock(); - // The destructor resets the context lost callback, so base::Unretained - // is safe, as long as the worker threads stop using the context before - // the output surface is destroyed. - worker_context_provider_->SetLostContextCallback(base::Bind( - &OutputSurface::DidLoseOutputSurface, base::Unretained(this))); - } } if (!success) @@ -217,11 +207,7 @@ void OutputSurface::SetWorkerContextShouldAggressivelyFreeResources( "OutputSurface::SetWorkerContextShouldAggressivelyFreeResources", "aggressively_free_resources", aggressively_free_resources); if (auto* context_provider = worker_context_provider()) { - // The context lock must be held while accessing the worker context. - base::AutoLock context_lock(*context_provider->GetLock()); - - // Allow context to bind to current thread. - context_provider->DetachFromThread(); + ContextProvider::ScopedContextLock scoped_context(context_provider); if (aggressively_free_resources) { context_provider->DeleteCachedResources(); @@ -231,9 +217,6 @@ void OutputSurface::SetWorkerContextShouldAggressivelyFreeResources( context_support->SetAggressivelyFreeResources( aggressively_free_resources); } - - // Allow context to bind to other threads. - context_provider->DetachFromThread(); } } |