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

Side by Side Diff: content/browser/android/synchronous_compositor_observer.cc

Issue 2383933002: Added message filter receiving frames from compositor
Patch Set: Created 4 years, 2 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "content/browser/android/synchronous_compositor_observer.h" 5 #include "content/browser/android/synchronous_compositor_observer.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 12 matching lines...) Expand all
23 // static 23 // static
24 SynchronousCompositorObserver* SynchronousCompositorObserver::GetOrCreateFor( 24 SynchronousCompositorObserver* SynchronousCompositorObserver::GetOrCreateFor(
25 int process_id) { 25 int process_id) {
26 auto itr = g_instances.Get().find(process_id); 26 auto itr = g_instances.Get().find(process_id);
27 if (itr != g_instances.Get().end()) 27 if (itr != g_instances.Get().end())
28 return itr->second; 28 return itr->second;
29 return new SynchronousCompositorObserver(process_id); 29 return new SynchronousCompositorObserver(process_id);
30 } 30 }
31 31
32 SynchronousCompositorObserver::SynchronousCompositorObserver(int process_id) 32 SynchronousCompositorObserver::SynchronousCompositorObserver(int process_id)
33 : render_process_host_(RenderProcessHost::FromID(process_id)), 33 : BrowserMessageFilter(SyncCompositorMsgStart),
34 render_process_host_(RenderProcessHost::FromID(process_id)),
34 window_android_in_vsync_(nullptr) { 35 window_android_in_vsync_(nullptr) {
35 DCHECK(render_process_host_); 36 DCHECK(render_process_host_);
36 DCHECK(!base::ContainsKey(g_instances.Get(), render_process_host_->GetID())); 37 DCHECK(!base::ContainsKey(g_instances.Get(), render_process_host_->GetID()));
37 g_instances.Get()[render_process_host_->GetID()] = this; 38 g_instances.Get()[render_process_host_->GetID()] = this;
38 render_process_host_->AddObserver(this); 39 render_process_host_->AddObserver(this);
39 } 40 }
40 41
41 SynchronousCompositorObserver::~SynchronousCompositorObserver() { 42 SynchronousCompositorObserver::~SynchronousCompositorObserver() {
42 DCHECK(compositor_host_pending_renderer_state_.empty()); 43 DCHECK(compositor_host_pending_renderer_state_.empty());
43 DCHECK(base::ContainsKey(g_instances.Get(), render_process_host_->GetID())); 44 DCHECK(base::ContainsKey(g_instances.Get(), render_process_host_->GetID()));
(...skipping 17 matching lines...) Expand all
61 DCHECK(compositor_host); 62 DCHECK(compositor_host);
62 DCHECK(!base::ContainsValue(compositor_host_pending_renderer_state_, 63 DCHECK(!base::ContainsValue(compositor_host_pending_renderer_state_,
63 compositor_host)); 64 compositor_host));
64 compositor_host_pending_renderer_state_.push_back(compositor_host); 65 compositor_host_pending_renderer_state_.push_back(compositor_host);
65 if (window_android_in_vsync_) 66 if (window_android_in_vsync_)
66 return; 67 return;
67 window_android_in_vsync_ = window_android; 68 window_android_in_vsync_ = window_android;
68 window_android_in_vsync_->AddObserver(this); 69 window_android_in_vsync_->AddObserver(this);
69 } 70 }
70 71
72 bool SynchronousCompositorObserver::OnMessageReceived(
73 const IPC::Message& message) {
74 bool handled = true;
75 IPC_BEGIN_MESSAGE_MAP(SynchronousCompositorObserver, message)
76 IPC_MESSAGE_HANDLER_GENERIC(SyncCompositorHostMsg_ReturnFrame,
77 ReceiveFrame(message))
78 IPC_MESSAGE_UNHANDLED(handled = false)
79 IPC_END_MESSAGE_MAP()
80 return handled;
81 }
82
83 bool SynchronousCompositorObserver::ReceiveFrame(const IPC::Message& message) {
84 SyncCompositorHostMsg_ReturnFrame::Param param;
85 if (!SyncCompositorHostMsg_ReturnFrame::Read(&message, &param))
86 return false;
87 uint32_t compositor_frame_sink_id = std::get<0>(param);
88 cc::CompositorFrame compositor_frame = std::move(std::get<1>(param));
89
90 content::SynchronousCompositor::Frame frame;
91 frame.frame.reset(new cc::CompositorFrame);
92 frame.compositor_frame_sink_id = compositor_frame_sink_id;
93 *frame.frame = std::move(compositor_frame);
94
95 if (!frame.frame->delegated_frame_data) {
96 frame.frame.reset();
97 }
98
99 std::unique_ptr<SynchronousCompositor::Frame> frame_ptr =
100 base::MakeUnique<SynchronousCompositor::Frame>();
101 frame_ptr->frame = std::move(frame.frame);
102 frame_ptr->compositor_frame_sink_id = frame.compositor_frame_sink_id;
103
104 int routing_id = message.routing_id();
105
106 future_map_[routing_id]->setFrame(std::move(frame_ptr));
107
108 return true;
109 }
110
111 void SynchronousCompositorObserver::SetFrameFuture(
112 const int routing_id,
113 const scoped_refptr<content::SynchronousCompositor::FrameFuture>&
114 frame_future) {
115 future_map_[routing_id] = std::move(frame_future);
116 }
117
71 void SynchronousCompositorObserver::OnCompositingDidCommit() { 118 void SynchronousCompositorObserver::OnCompositingDidCommit() {
72 NOTREACHED(); 119 NOTREACHED();
73 } 120 }
74 121
75 void SynchronousCompositorObserver::OnRootWindowVisibilityChanged( 122 void SynchronousCompositorObserver::OnRootWindowVisibilityChanged(
76 bool visible) { 123 bool visible) {
77 NOTREACHED(); 124 NOTREACHED();
78 } 125 }
79 126
80 void SynchronousCompositorObserver::OnAttachCompositor() { 127 void SynchronousCompositorObserver::OnAttachCompositor() {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 169
123 void SynchronousCompositorObserver::OnActivityStopped() { 170 void SynchronousCompositorObserver::OnActivityStopped() {
124 NOTREACHED(); 171 NOTREACHED();
125 } 172 }
126 173
127 void SynchronousCompositorObserver::OnActivityStarted() { 174 void SynchronousCompositorObserver::OnActivityStarted() {
128 NOTREACHED(); 175 NOTREACHED();
129 } 176 }
130 177
131 } // namespace content 178 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/synchronous_compositor_observer.h ('k') | content/browser/renderer_host/render_process_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698