diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-06-18 14:10:49 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2015-06-18 13:53:24 +0000 |
commit | 813fbf95af77a531c57a8c497345ad2c61d475b3 (patch) | |
tree | 821b2c8de8365f21b6c9ba17a236fb3006a1d506 /chromium/cc/output/output_surface.cc | |
parent | af6588f8d723931a298c995fa97259bb7f7deb55 (diff) | |
download | qtwebengine-chromium-813fbf95af77a531c57a8c497345ad2c61d475b3.tar.gz |
BASELINE: Update chromium to 44.0.2403.47
Change-Id: Ie056fedba95cf5e5c76b30c4b2c80fca4764aa2f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'chromium/cc/output/output_surface.cc')
-rw-r--r-- | chromium/cc/output/output_surface.cc | 131 |
1 files changed, 56 insertions, 75 deletions
diff --git a/chromium/cc/output/output_surface.cc b/chromium/cc/output/output_surface.cc index 3502927f84b..670578ad6b0 100644 --- a/chromium/cc/output/output_surface.cc +++ b/chromium/cc/output/output_surface.cc @@ -5,8 +5,10 @@ #include "cc/output/output_surface.h" #include "base/bind.h" -#include "base/debug/trace_event.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" +#include "base/trace_event/trace_event.h" #include "cc/output/managed_memory_policy.h" #include "cc/output/output_surface_client.h" #include "gpu/GLES2/gl2extchromium.h" @@ -18,31 +20,37 @@ namespace cc { OutputSurface::OutputSurface( - const scoped_refptr<ContextProvider>& context_provider) + const scoped_refptr<ContextProvider>& context_provider, + const scoped_refptr<ContextProvider>& worker_context_provider, + scoped_ptr<SoftwareOutputDevice> software_device) : client_(NULL), context_provider_(context_provider), + worker_context_provider_(worker_context_provider), + software_device_(software_device.Pass()), device_scale_factor_(-1), external_stencil_test_enabled_(false), weak_ptr_factory_(this) { } +OutputSurface::OutputSurface( + const scoped_refptr<ContextProvider>& context_provider) + : OutputSurface(context_provider, nullptr, nullptr) { +} + +OutputSurface::OutputSurface( + const scoped_refptr<ContextProvider>& context_provider, + const scoped_refptr<ContextProvider>& worker_context_provider) + : OutputSurface(context_provider, worker_context_provider, nullptr) { +} + OutputSurface::OutputSurface(scoped_ptr<SoftwareOutputDevice> software_device) - : client_(NULL), - software_device_(software_device.Pass()), - device_scale_factor_(-1), - external_stencil_test_enabled_(false), - weak_ptr_factory_(this) { + : OutputSurface(nullptr, nullptr, software_device.Pass()) { } OutputSurface::OutputSurface( const scoped_refptr<ContextProvider>& context_provider, scoped_ptr<SoftwareOutputDevice> software_device) - : client_(NULL), - context_provider_(context_provider), - software_device_(software_device.Pass()), - device_scale_factor_(-1), - external_stencil_test_enabled_(false), - weak_ptr_factory_(this) { + : OutputSurface(context_provider, nullptr, software_device.Pass()) { } void OutputSurface::CommitVSyncParameters(base::TimeTicks timebase, @@ -91,7 +99,16 @@ void OutputSurface::SetExternalDrawConstraints( } OutputSurface::~OutputSurface() { - ResetContext3d(); + if (context_provider_.get()) { + context_provider_->SetLostContextCallback( + ContextProvider::LostContextCallback()); + context_provider_->SetMemoryPolicyChangedCallback( + ContextProvider::MemoryPolicyChangedCallback()); + } + if (worker_context_provider_.get()) { + worker_context_provider_->SetLostContextCallback( + ContextProvider::LostContextCallback()); + } } bool OutputSurface::HasExternalStencilTest() const { @@ -105,71 +122,32 @@ bool OutputSurface::BindToClient(OutputSurfaceClient* client) { if (context_provider_.get()) { success = context_provider_->BindToCurrentThread(); - if (success) - SetUpContext3d(); + if (success) { + context_provider_->SetLostContextCallback(base::Bind( + &OutputSurface::DidLoseOutputSurface, base::Unretained(this))); + context_provider_->SetMemoryPolicyChangedCallback( + base::Bind(&OutputSurface::SetMemoryPolicy, base::Unretained(this))); + } } - if (!success) - client_ = NULL; - - return success; -} - -bool OutputSurface::InitializeAndSetContext3d( - scoped_refptr<ContextProvider> context_provider) { - DCHECK(!context_provider_.get()); - DCHECK(context_provider.get()); - DCHECK(client_); - - bool success = false; - if (context_provider->BindToCurrentThread()) { - context_provider_ = context_provider; - SetUpContext3d(); - client_->DeferredInitialize(); - success = true; + if (success && worker_context_provider_.get()) { + success = worker_context_provider_->BindToCurrentThread(); + 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) - ResetContext3d(); + client_ = NULL; return success; } -void OutputSurface::ReleaseGL() { - DCHECK(client_); - DCHECK(context_provider_.get()); - client_->ReleaseGL(); - DCHECK(!context_provider_.get()); -} - -void OutputSurface::SetUpContext3d() { - DCHECK(context_provider_.get()); - DCHECK(client_); - - context_provider_->SetLostContextCallback( - base::Bind(&OutputSurface::DidLoseOutputSurface, - base::Unretained(this))); - context_provider_->SetMemoryPolicyChangedCallback( - base::Bind(&OutputSurface::SetMemoryPolicy, - base::Unretained(this))); -} - -void OutputSurface::ReleaseContextProvider() { - DCHECK(client_); - DCHECK(context_provider_.get()); - ResetContext3d(); -} - -void OutputSurface::ResetContext3d() { - if (context_provider_.get()) { - context_provider_->SetLostContextCallback( - ContextProvider::LostContextCallback()); - context_provider_->SetMemoryPolicyChangedCallback( - ContextProvider::MemoryPolicyChangedCallback()); - } - context_provider_ = NULL; -} - void OutputSurface::EnsureBackbuffer() { if (software_device_) software_device_->EnsureBackbuffer(); @@ -206,10 +184,9 @@ void OutputSurface::BindFramebuffer() { } void OutputSurface::PostSwapBuffersComplete() { - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&OutputSurface::OnSwapBuffersComplete, - weak_ptr_factory_.GetWeakPtr())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&OutputSurface::OnSwapBuffersComplete, + weak_ptr_factory_.GetWeakPtr())); } // We don't post tasks bound to the client directly since they might run @@ -228,4 +205,8 @@ void OutputSurface::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { client_->SetMemoryPolicy(policy); } +OverlayCandidateValidator* OutputSurface::GetOverlayCandidateValidator() const { + return nullptr; +} + } // namespace cc |