Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: cc/trees/thread_proxy.cc

Issue 1336733002: Re-land: cc: Implement shared worker contexts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix LayerTreeHostClientTakeAwayOutputSurface test. Content provider is always destroyed on the clie… Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/thread_proxy.h" 5 #include "cc/trees/thread_proxy.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface"); 203 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface");
204 DCHECK(IsMainThread()); 204 DCHECK(IsMainThread());
205 layer_tree_host()->DidLoseOutputSurface(); 205 layer_tree_host()->DidLoseOutputSurface();
206 } 206 }
207 207
208 void ThreadProxy::RequestNewOutputSurface() { 208 void ThreadProxy::RequestNewOutputSurface() {
209 DCHECK(IsMainThread()); 209 DCHECK(IsMainThread());
210 layer_tree_host()->RequestNewOutputSurface(); 210 layer_tree_host()->RequestNewOutputSurface();
211 } 211 }
212 212
213 void ThreadProxy::SetOutputSurface(scoped_ptr<OutputSurface> output_surface) { 213 void ThreadProxy::SetOutputSurface(OutputSurface* output_surface) {
214 Proxy::ImplThreadTaskRunner()->PostTask( 214 Proxy::ImplThreadTaskRunner()->PostTask(
215 FROM_HERE, 215 FROM_HERE, base::Bind(&ThreadProxy::InitializeOutputSurfaceOnImplThread,
216 base::Bind(&ThreadProxy::InitializeOutputSurfaceOnImplThread, 216 impl_thread_weak_ptr_, output_surface));
217 impl_thread_weak_ptr_, base::Passed(&output_surface)));
218 } 217 }
219 218
220 scoped_ptr<OutputSurface> ThreadProxy::ReleaseOutputSurface() { 219 void ThreadProxy::ReleaseOutputSurface() {
221 DCHECK(IsMainThread()); 220 DCHECK(IsMainThread());
222 DCHECK(layer_tree_host()->output_surface_lost()); 221 DCHECK(layer_tree_host()->output_surface_lost());
223 222
224 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 223 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
225 CompletionEvent completion; 224 CompletionEvent completion;
226 scoped_ptr<OutputSurface> output_surface;
227 Proxy::ImplThreadTaskRunner()->PostTask( 225 Proxy::ImplThreadTaskRunner()->PostTask(
228 FROM_HERE, 226 FROM_HERE, base::Bind(&ThreadProxy::ReleaseOutputSurfaceOnImplThread,
229 base::Bind(&ThreadProxy::ReleaseOutputSurfaceOnImplThread, 227 impl_thread_weak_ptr_, &completion));
230 impl_thread_weak_ptr_, &completion, &output_surface));
231 completion.Wait(); 228 completion.Wait();
232 return output_surface;
233 } 229 }
234 230
235 void ThreadProxy::DidInitializeOutputSurface( 231 void ThreadProxy::DidInitializeOutputSurface(
236 bool success, 232 bool success,
237 const RendererCapabilities& capabilities) { 233 const RendererCapabilities& capabilities) {
238 TRACE_EVENT0("cc", "ThreadProxy::DidInitializeOutputSurface"); 234 TRACE_EVENT0("cc", "ThreadProxy::DidInitializeOutputSurface");
239 DCHECK(IsMainThread()); 235 DCHECK(IsMainThread());
240 236
241 if (!success) { 237 if (!success) {
242 layer_tree_host()->DidFailToInitializeOutputSurface(); 238 layer_tree_host()->DidFailToInitializeOutputSurface();
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 this, scheduler_settings, impl().layer_tree_host_id, 1030 this, scheduler_settings, impl().layer_tree_host_id,
1035 ImplThreadTaskRunner(), impl().external_begin_frame_source.get(), 1031 ImplThreadTaskRunner(), impl().external_begin_frame_source.get(),
1036 compositor_timing_history.Pass()); 1032 compositor_timing_history.Pass());
1037 1033
1038 impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible()); 1034 impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible());
1039 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); 1035 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr();
1040 completion->Signal(); 1036 completion->Signal();
1041 } 1037 }
1042 1038
1043 void ThreadProxy::InitializeOutputSurfaceOnImplThread( 1039 void ThreadProxy::InitializeOutputSurfaceOnImplThread(
1044 scoped_ptr<OutputSurface> output_surface) { 1040 OutputSurface* output_surface) {
1045 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); 1041 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread");
1046 DCHECK(IsImplThread()); 1042 DCHECK(IsImplThread());
1047 1043
1048 LayerTreeHostImpl* host_impl = impl().layer_tree_host_impl.get(); 1044 LayerTreeHostImpl* host_impl = impl().layer_tree_host_impl.get();
1049 bool success = host_impl->InitializeRenderer(output_surface.Pass()); 1045 bool success = host_impl->InitializeRenderer(output_surface);
1050 RendererCapabilities capabilities; 1046 RendererCapabilities capabilities;
1051 if (success) { 1047 if (success) {
1052 capabilities = 1048 capabilities =
1053 host_impl->GetRendererCapabilities().MainThreadCapabilities(); 1049 host_impl->GetRendererCapabilities().MainThreadCapabilities();
1054 } 1050 }
1055 1051
1056 Proxy::MainThreadTaskRunner()->PostTask( 1052 Proxy::MainThreadTaskRunner()->PostTask(
1057 FROM_HERE, 1053 FROM_HERE,
1058 base::Bind(&ThreadProxy::DidInitializeOutputSurface, 1054 base::Bind(&ThreadProxy::DidInitializeOutputSurface,
1059 main_thread_weak_ptr_, 1055 main_thread_weak_ptr_,
1060 success, 1056 success,
1061 capabilities)); 1057 capabilities));
1062 1058
1063 if (success) 1059 if (success)
1064 impl().scheduler->DidCreateAndInitializeOutputSurface(); 1060 impl().scheduler->DidCreateAndInitializeOutputSurface();
1065 } 1061 }
1066 1062
1067 void ThreadProxy::ReleaseOutputSurfaceOnImplThread( 1063 void ThreadProxy::ReleaseOutputSurfaceOnImplThread(
1068 CompletionEvent* completion, 1064 CompletionEvent* completion) {
1069 scoped_ptr<OutputSurface>* output_surface) {
1070 DCHECK(IsImplThread()); 1065 DCHECK(IsImplThread());
1071 1066
1072 // Unlike DidLoseOutputSurfaceOnImplThread, we don't need to call 1067 // Unlike DidLoseOutputSurfaceOnImplThread, we don't need to call
1073 // LayerTreeHost::DidLoseOutputSurface since it already knows. 1068 // LayerTreeHost::DidLoseOutputSurface since it already knows.
1074 impl().scheduler->DidLoseOutputSurface(); 1069 impl().scheduler->DidLoseOutputSurface();
1075 *output_surface = impl().layer_tree_host_impl->ReleaseOutputSurface(); 1070 impl().layer_tree_host_impl->ReleaseOutputSurface();
1076 completion->Signal(); 1071 completion->Signal();
1077 } 1072 }
1078 1073
1079 void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { 1074 void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) {
1080 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); 1075 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread");
1081 DCHECK(IsImplThread()); 1076 DCHECK(IsImplThread());
1082 if (impl().layer_tree_host_impl->output_surface()) { 1077 if (impl().layer_tree_host_impl->output_surface()) {
1083 ContextProvider* context_provider = 1078 ContextProvider* context_provider =
1084 impl().layer_tree_host_impl->output_surface()->context_provider(); 1079 impl().layer_tree_host_impl->output_surface()->context_provider();
1085 if (context_provider) 1080 if (context_provider)
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 1243
1249 void ThreadProxy::PostFrameTimingEvents( 1244 void ThreadProxy::PostFrameTimingEvents(
1250 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 1245 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
1251 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { 1246 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
1252 DCHECK(IsMainThread()); 1247 DCHECK(IsMainThread());
1253 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(), 1248 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(),
1254 main_frame_events.Pass()); 1249 main_frame_events.Pass());
1255 } 1250 }
1256 1251
1257 } // namespace cc 1252 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | content/browser/android/in_process/synchronous_compositor_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698