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

Side by Side Diff: blimp/client/core/compositor/blimp_compositor.cc

Issue 2320823003: cc/blimp: Remove Initialize and Close messages. (Closed)
Patch Set: format Created 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "blimp/client/core/compositor/blimp_compositor.h" 5 #include "blimp/client/core/compositor/blimp_compositor.h"
6 6
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 } // namespace 57 } // namespace
58 58
59 BlimpCompositor::BlimpCompositor( 59 BlimpCompositor::BlimpCompositor(
60 int render_widget_id, 60 int render_widget_id,
61 BlimpCompositorDependencies* compositor_dependencies, 61 BlimpCompositorDependencies* compositor_dependencies,
62 BlimpCompositorClient* client) 62 BlimpCompositorClient* client)
63 : render_widget_id_(render_widget_id), 63 : render_widget_id_(render_widget_id),
64 client_(client), 64 client_(client),
65 compositor_dependencies_(compositor_dependencies), 65 compositor_dependencies_(compositor_dependencies),
66 host_should_be_visible_(false),
67 output_surface_(nullptr), 66 output_surface_(nullptr),
68 output_surface_request_pending_(false), 67 output_surface_request_pending_(false),
69 layer_(cc::Layer::Create()), 68 layer_(cc::Layer::Create()),
70 remote_proto_channel_receiver_(nullptr), 69 remote_proto_channel_receiver_(nullptr),
71 weak_ptr_factory_(this) { 70 weak_ptr_factory_(this) {
72 DCHECK(thread_checker_.CalledOnValidThread()); 71 DCHECK(thread_checker_.CalledOnValidThread());
73 72
74 surface_id_allocator_ = base::MakeUnique<cc::SurfaceIdAllocator>( 73 surface_id_allocator_ = base::MakeUnique<cc::SurfaceIdAllocator>(
75 GetEmbedderDeps()->AllocateSurfaceClientId()); 74 GetEmbedderDeps()->AllocateSurfaceClientId());
76 GetEmbedderDeps()->GetSurfaceManager()->RegisterSurfaceClientId( 75 GetEmbedderDeps()->GetSurfaceManager()->RegisterSurfaceClientId(
77 surface_id_allocator_->client_id()); 76 surface_id_allocator_->client_id());
77 CreateLayerTreeHost();
78 } 78 }
79 79
80 BlimpCompositor::~BlimpCompositor() { 80 BlimpCompositor::~BlimpCompositor() {
81 DCHECK(thread_checker_.CalledOnValidThread()); 81 DCHECK(thread_checker_.CalledOnValidThread());
82 82
83 if (host_) 83 DestroyLayerTreeHost();
84 DestroyLayerTreeHost();
85
86 GetEmbedderDeps()->GetSurfaceManager()->InvalidateSurfaceClientId( 84 GetEmbedderDeps()->GetSurfaceManager()->InvalidateSurfaceClientId(
87 surface_id_allocator_->client_id()); 85 surface_id_allocator_->client_id());
88 } 86 }
89 87
90 void BlimpCompositor::SetVisible(bool visible) { 88 void BlimpCompositor::SetVisible(bool visible) {
91 host_should_be_visible_ = visible; 89 host_->SetVisible(visible);
92 if (host_)
93 host_->SetVisible(host_should_be_visible_);
94 } 90 }
95 91
96 bool BlimpCompositor::OnTouchEvent(const ui::MotionEvent& motion_event) { 92 bool BlimpCompositor::OnTouchEvent(const ui::MotionEvent& motion_event) {
97 if (input_manager_) 93 if (input_manager_)
98 return input_manager_->OnTouchEvent(motion_event); 94 return input_manager_->OnTouchEvent(motion_event);
99 return false; 95 return false;
100 } 96 }
101 97
102 void BlimpCompositor::RequestNewOutputSurface() { 98 void BlimpCompositor::RequestNewOutputSurface() {
103 DCHECK(!surface_factory_); 99 DCHECK(!surface_factory_);
(...skipping 25 matching lines...) Expand all
129 void BlimpCompositor::OnCompositorMessageReceived( 125 void BlimpCompositor::OnCompositorMessageReceived(
130 std::unique_ptr<cc::proto::CompositorMessage> message) { 126 std::unique_ptr<cc::proto::CompositorMessage> message) {
131 DCHECK(message->has_to_impl()); 127 DCHECK(message->has_to_impl());
132 const cc::proto::CompositorMessageToImpl& to_impl_proto = message->to_impl(); 128 const cc::proto::CompositorMessageToImpl& to_impl_proto = message->to_impl();
133 129
134 DCHECK(to_impl_proto.has_message_type()); 130 DCHECK(to_impl_proto.has_message_type());
135 switch (to_impl_proto.message_type()) { 131 switch (to_impl_proto.message_type()) {
136 case cc::proto::CompositorMessageToImpl::UNKNOWN: 132 case cc::proto::CompositorMessageToImpl::UNKNOWN:
137 NOTIMPLEMENTED() << "Ignoring message of UNKNOWN type"; 133 NOTIMPLEMENTED() << "Ignoring message of UNKNOWN type";
138 break; 134 break;
139 case cc::proto::CompositorMessageToImpl::INITIALIZE_IMPL:
140 DCHECK(!host_);
141
142 // Create the remote client LayerTreeHost for the compositor.
143 CreateLayerTreeHost();
144 break;
145 case cc::proto::CompositorMessageToImpl::CLOSE_IMPL:
146 DCHECK(host_);
147
148 // Destroy the remote client LayerTreeHost for the compositor.
149 DestroyLayerTreeHost();
150 break;
151 default: 135 default:
152 // We should have a receiver if we're getting compositor messages that 136 // We should have a receiver if we're getting compositor messages that
153 // are not INITIALIZE_IMPL or CLOSE_IMPL. 137 // are not INITIALIZE_IMPL or CLOSE_IMPL.
154 DCHECK(remote_proto_channel_receiver_); 138 DCHECK(remote_proto_channel_receiver_);
155 remote_proto_channel_receiver_->OnProtoReceived(std::move(message)); 139 remote_proto_channel_receiver_->OnProtoReceived(std::move(message));
156 } 140 }
157 } 141 }
158 142
159 void BlimpCompositor::OnContextProvidersCreated( 143 void BlimpCompositor::OnContextProvidersCreated(
160 const scoped_refptr<cc::ContextProvider>& compositor_context_provider, 144 const scoped_refptr<cc::ContextProvider>& compositor_context_provider,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 settings->abort_commit_before_output_surface_creation = false; 270 settings->abort_commit_before_output_surface_creation = false;
287 params.settings = settings; 271 params.settings = settings;
288 272
289 params.animation_host = cc::AnimationHost::CreateMainInstance(); 273 params.animation_host = cc::AnimationHost::CreateMainInstance();
290 274
291 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner = 275 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner =
292 compositor_dependencies_->GetCompositorTaskRunner(); 276 compositor_dependencies_->GetCompositorTaskRunner();
293 277
294 host_ = cc::LayerTreeHost::CreateRemoteClient( 278 host_ = cc::LayerTreeHost::CreateRemoteClient(
295 this /* remote_proto_channel */, compositor_task_runner, &params); 279 this /* remote_proto_channel */, compositor_task_runner, &params);
296 host_->SetVisible(host_should_be_visible_);
297 280
298 DCHECK(!input_manager_); 281 DCHECK(!input_manager_);
299 input_manager_ = BlimpInputManager::Create( 282 input_manager_ = BlimpInputManager::Create(
300 this, base::ThreadTaskRunnerHandle::Get(), compositor_task_runner, 283 this, base::ThreadTaskRunnerHandle::Get(), compositor_task_runner,
301 host_->GetInputHandler()); 284 host_->GetInputHandler());
302 } 285 }
303 286
304 void BlimpCompositor::DestroyLayerTreeHost() { 287 void BlimpCompositor::DestroyLayerTreeHost() {
305 DCHECK(host_); 288 DCHECK(host_);
306 VLOG(1) << "Destroying LayerTreeHost for render widget: " 289 VLOG(1) << "Destroying LayerTreeHost for render widget: "
(...skipping 15 matching lines...) Expand all
322 // Cancel any outstanding OutputSurface requests. That way if we get an async 305 // Cancel any outstanding OutputSurface requests. That way if we get an async
323 // callback related to the old request we know to drop it. 306 // callback related to the old request we know to drop it.
324 output_surface_request_pending_ = false; 307 output_surface_request_pending_ = false;
325 308
326 // Make sure we don't have a receiver at this point. 309 // Make sure we don't have a receiver at this point.
327 DCHECK(!remote_proto_channel_receiver_); 310 DCHECK(!remote_proto_channel_receiver_);
328 } 311 }
329 312
330 } // namespace client 313 } // namespace client
331 } // namespace blimp 314 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/core/compositor/blimp_compositor.h ('k') | blimp/client/core/compositor/blimp_compositor_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698