Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/output/output_surface.h" | 5 #include "cc/output/output_surface.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "cc/output/managed_memory_policy.h" | 10 #include "cc/output/managed_memory_policy.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 if (!success) | 130 if (!success) |
| 131 client_ = NULL; | 131 client_ = NULL; |
| 132 | 132 |
| 133 return success; | 133 return success; |
| 134 } | 134 } |
| 135 | 135 |
| 136 bool OutputSurface::InitializeAndSetContext3d( | 136 bool OutputSurface::InitializeAndSetContext3d( |
| 137 scoped_refptr<ContextProvider> context_provider) { | 137 scoped_refptr<ContextProvider> context_provider, |
| 138 scoped_refptr<ContextProvider> worker_context_provider) { | |
| 138 DCHECK(!context_provider_.get()); | 139 DCHECK(!context_provider_.get()); |
| 139 DCHECK(context_provider.get()); | 140 DCHECK(context_provider.get()); |
| 140 DCHECK(client_); | 141 DCHECK(client_); |
| 141 | 142 |
| 142 bool success = false; | 143 bool success = context_provider->BindToCurrentThread(); |
| 143 if (context_provider->BindToCurrentThread()) { | 144 if (success) { |
| 144 context_provider_ = context_provider; | 145 context_provider_ = context_provider; |
| 145 SetUpContext3d(); | 146 SetUpContext3d(); |
| 146 client_->DeferredInitialize(); | 147 } |
| 147 success = true; | 148 if (success && worker_context_provider.get()) { |
| 149 success = worker_context_provider->BindToCurrentThread(); | |
|
boliu
2015/02/13 20:25:52
Was trying this in webview with a ganesh page, and
vmiura
2015/02/13 21:28:32
I think I need to implement ContextProviderInProce
| |
| 150 if (success) { | |
| 151 worker_context_provider_ = worker_context_provider; | |
| 152 // The destructor resets the context lost callback, so base::Unretained | |
| 153 // is safe, as long as the worker threads stop using the context before | |
| 154 // the output surface is destroyed. | |
| 155 worker_context_provider_->SetLostContextCallback(base::Bind( | |
|
boliu
2015/02/13 20:25:52
Same threading problem on the context loss callbac
vmiura
2015/02/13 21:28:32
Same here.
We bind to the compositor thread here,
| |
| 156 &OutputSurface::DidLoseOutputSurface, base::Unretained(this))); | |
| 157 } | |
| 148 } | 158 } |
| 149 | 159 |
| 150 if (!success) | 160 if (!success) |
| 151 ResetContext3d(); | 161 ResetContext3d(); |
| 162 else | |
| 163 client_->DeferredInitialize(); | |
| 152 | 164 |
| 153 return success; | 165 return success; |
| 154 } | 166 } |
| 155 | 167 |
| 156 void OutputSurface::ReleaseGL() { | 168 void OutputSurface::ReleaseGL() { |
| 157 DCHECK(client_); | 169 DCHECK(client_); |
| 158 DCHECK(context_provider_.get()); | 170 DCHECK(context_provider_.get()); |
| 159 client_->ReleaseGL(); | 171 client_->ReleaseGL(); |
| 160 DCHECK(!context_provider_.get()); | 172 DCHECK(!context_provider_.get()); |
| 161 } | 173 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 TRACE_EVENT1("cc", "OutputSurface::SetMemoryPolicy", | 257 TRACE_EVENT1("cc", "OutputSurface::SetMemoryPolicy", |
| 246 "bytes_limit_when_visible", policy.bytes_limit_when_visible); | 258 "bytes_limit_when_visible", policy.bytes_limit_when_visible); |
| 247 // Just ignore the memory manager when it says to set the limit to zero | 259 // Just ignore the memory manager when it says to set the limit to zero |
| 248 // bytes. This will happen when the memory manager thinks that the renderer | 260 // bytes. This will happen when the memory manager thinks that the renderer |
| 249 // is not visible (which the renderer knows better). | 261 // is not visible (which the renderer knows better). |
| 250 if (policy.bytes_limit_when_visible) | 262 if (policy.bytes_limit_when_visible) |
| 251 client_->SetMemoryPolicy(policy); | 263 client_->SetMemoryPolicy(policy); |
| 252 } | 264 } |
| 253 | 265 |
| 254 } // namespace cc | 266 } // namespace cc |
| OLD | NEW |