| OLD | NEW |
| 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/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 } // namespace | 58 } // namespace |
| 59 | 59 |
| 60 BlimpCompositor::BlimpCompositor( | 60 BlimpCompositor::BlimpCompositor( |
| 61 int render_widget_id, | 61 int render_widget_id, |
| 62 BlimpCompositorDependencies* compositor_dependencies, | 62 BlimpCompositorDependencies* compositor_dependencies, |
| 63 BlimpCompositorClient* client) | 63 BlimpCompositorClient* client) |
| 64 : render_widget_id_(render_widget_id), | 64 : render_widget_id_(render_widget_id), |
| 65 client_(client), | 65 client_(client), |
| 66 compositor_dependencies_(compositor_dependencies), | 66 compositor_dependencies_(compositor_dependencies), |
| 67 frame_sink_id_(compositor_dependencies_->GetEmbedderDependencies() |
| 68 ->AllocateFrameSinkId()), |
| 67 proxy_client_(nullptr), | 69 proxy_client_(nullptr), |
| 68 compositor_frame_sink_request_pending_(false), | 70 compositor_frame_sink_request_pending_(false), |
| 69 layer_(cc::Layer::Create()), | 71 layer_(cc::Layer::Create()), |
| 70 remote_proto_channel_receiver_(nullptr), | 72 remote_proto_channel_receiver_(nullptr), |
| 71 outstanding_commits_(0U), | 73 outstanding_commits_(0U), |
| 72 weak_ptr_factory_(this) { | 74 weak_ptr_factory_(this) { |
| 73 DCHECK(thread_checker_.CalledOnValidThread()); | 75 DCHECK(thread_checker_.CalledOnValidThread()); |
| 74 | 76 |
| 75 surface_id_allocator_ = base::MakeUnique<cc::SurfaceIdAllocator>( | 77 surface_id_allocator_ = |
| 76 GetEmbedderDeps()->AllocateFrameSinkId()); | 78 base::MakeUnique<cc::SurfaceIdAllocator>(frame_sink_id_); |
| 77 GetEmbedderDeps()->GetSurfaceManager()->RegisterFrameSinkId( | 79 GetEmbedderDeps()->GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); |
| 78 surface_id_allocator_->frame_sink_id()); | |
| 79 CreateLayerTreeHost(); | 80 CreateLayerTreeHost(); |
| 80 } | 81 } |
| 81 | 82 |
| 82 BlimpCompositor::~BlimpCompositor() { | 83 BlimpCompositor::~BlimpCompositor() { |
| 83 DCHECK(thread_checker_.CalledOnValidThread()); | 84 DCHECK(thread_checker_.CalledOnValidThread()); |
| 84 | 85 |
| 85 DestroyLayerTreeHost(); | 86 DestroyLayerTreeHost(); |
| 86 GetEmbedderDeps()->GetSurfaceManager()->InvalidateFrameSinkId( | 87 GetEmbedderDeps()->GetSurfaceManager()->InvalidateFrameSinkId(frame_sink_id_); |
| 87 surface_id_allocator_->frame_sink_id()); | |
| 88 | 88 |
| 89 CheckPendingCommitCounts(true /* flush */); | 89 CheckPendingCommitCounts(true /* flush */); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void BlimpCompositor::SetVisible(bool visible) { | 92 void BlimpCompositor::SetVisible(bool visible) { |
| 93 host_->SetVisible(visible); | 93 host_->SetVisible(visible); |
| 94 | 94 |
| 95 if (!visible) | 95 if (!visible) |
| 96 CheckPendingCommitCounts(true /* flush */); | 96 CheckPendingCommitCounts(true /* flush */); |
| 97 } | 97 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 client_->SendWebGestureEvent(render_widget_id_, gesture_event); | 204 client_->SendWebGestureEvent(render_widget_id_, gesture_event); |
| 205 } | 205 } |
| 206 | 206 |
| 207 void BlimpCompositor::BindToProxyClient( | 207 void BlimpCompositor::BindToProxyClient( |
| 208 base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client) { | 208 base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client) { |
| 209 DCHECK(thread_checker_.CalledOnValidThread()); | 209 DCHECK(thread_checker_.CalledOnValidThread()); |
| 210 DCHECK(!surface_factory_); | 210 DCHECK(!surface_factory_); |
| 211 | 211 |
| 212 proxy_client_ = proxy_client; | 212 proxy_client_ = proxy_client; |
| 213 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>( | 213 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>( |
| 214 GetEmbedderDeps()->GetSurfaceManager(), this); | 214 frame_sink_id_, GetEmbedderDeps()->GetSurfaceManager(), this); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void BlimpCompositor::SwapCompositorFrame(cc::CompositorFrame frame) { | 217 void BlimpCompositor::SwapCompositorFrame(cc::CompositorFrame frame) { |
| 218 DCHECK(thread_checker_.CalledOnValidThread()); | 218 DCHECK(thread_checker_.CalledOnValidThread()); |
| 219 DCHECK(surface_factory_); | 219 DCHECK(surface_factory_); |
| 220 | 220 |
| 221 cc::RenderPass* root_pass = | 221 cc::RenderPass* root_pass = |
| 222 frame.delegated_frame_data->render_pass_list.back().get(); | 222 frame.delegated_frame_data->render_pass_list.back().get(); |
| 223 gfx::Size surface_size = root_pass->output_rect.size(); | 223 gfx::Size surface_size = root_pass->output_rect.size(); |
| 224 | 224 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 it->second.Run(); | 349 it->second.Run(); |
| 350 it = pending_commit_trackers_.erase(it); | 350 it = pending_commit_trackers_.erase(it); |
| 351 } else { | 351 } else { |
| 352 ++it; | 352 ++it; |
| 353 } | 353 } |
| 354 } | 354 } |
| 355 } | 355 } |
| 356 | 356 |
| 357 } // namespace client | 357 } // namespace client |
| 358 } // namespace blimp | 358 } // namespace blimp |
| OLD | NEW |