| Index: cc/output/output_surface.cc
|
| diff --git a/cc/output/output_surface.cc b/cc/output/output_surface.cc
|
| index b65887e960262262c0f514492f56a49ac0a0e7c3..b1a2b9a4647121746fcd342a22d5f2be7d9cd24c 100644
|
| --- a/cc/output/output_surface.cc
|
| +++ b/cc/output/output_surface.cc
|
| @@ -18,31 +18,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,
|
| @@ -109,6 +115,18 @@ bool OutputSurface::BindToClient(OutputSurfaceClient* client) {
|
| SetUpContext3d();
|
| }
|
|
|
| + 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)
|
| client_ = NULL;
|
|
|
| @@ -116,21 +134,33 @@ bool OutputSurface::BindToClient(OutputSurfaceClient* client) {
|
| }
|
|
|
| bool OutputSurface::InitializeAndSetContext3d(
|
| - scoped_refptr<ContextProvider> context_provider) {
|
| + scoped_refptr<ContextProvider> context_provider,
|
| + scoped_refptr<ContextProvider> worker_context_provider) {
|
| DCHECK(!context_provider_.get());
|
| DCHECK(context_provider.get());
|
| DCHECK(client_);
|
|
|
| - bool success = false;
|
| - if (context_provider->BindToCurrentThread()) {
|
| + bool success = context_provider->BindToCurrentThread();
|
| + if (success) {
|
| 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_ = worker_context_provider;
|
| + // 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();
|
| + else
|
| + client_->DeferredInitialize();
|
|
|
| return success;
|
| }
|
| @@ -167,7 +197,12 @@ void OutputSurface::ResetContext3d() {
|
| context_provider_->SetMemoryPolicyChangedCallback(
|
| ContextProvider::MemoryPolicyChangedCallback());
|
| }
|
| + if (worker_context_provider_.get()) {
|
| + worker_context_provider_->SetLostContextCallback(
|
| + ContextProvider::LostContextCallback());
|
| + }
|
| context_provider_ = NULL;
|
| + worker_context_provider_ = NULL;
|
| }
|
|
|
| void OutputSurface::EnsureBackbuffer() {
|
|
|