| OLD | NEW |
| 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_browser_filter.h" | 5 #include "content/browser/android/synchronous_compositor_browser_filter.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 DCHECK(!window_android_in_vsync_ || | 38 DCHECK(!window_android_in_vsync_ || |
| 39 window_android_in_vsync_ == window_android) | 39 window_android_in_vsync_ == window_android) |
| 40 << !!window_android_in_vsync_; | 40 << !!window_android_in_vsync_; |
| 41 DCHECK(compositor_host); | 41 DCHECK(compositor_host); |
| 42 DCHECK(!base::ContainsValue(compositor_host_pending_renderer_state_, | 42 DCHECK(!base::ContainsValue(compositor_host_pending_renderer_state_, |
| 43 compositor_host)); | 43 compositor_host)); |
| 44 compositor_host_pending_renderer_state_.push_back(compositor_host); | 44 compositor_host_pending_renderer_state_.push_back(compositor_host); |
| 45 if (window_android_in_vsync_) | 45 if (window_android_in_vsync_) |
| 46 return; | 46 return; |
| 47 window_android_in_vsync_ = window_android; | 47 window_android_in_vsync_ = window_android; |
| 48 window_android_in_vsync_->AddObserver(this); | 48 window_android_in_vsync_->GetBeginFrameSource()->AddObserver(this); |
| 49 } | 49 } |
| 50 | 50 |
| 51 bool SynchronousCompositorBrowserFilter::OnMessageReceived( | 51 bool SynchronousCompositorBrowserFilter::OnMessageReceived( |
| 52 const IPC::Message& message) { | 52 const IPC::Message& message) { |
| 53 bool handled = true; | 53 bool handled = true; |
| 54 IPC_BEGIN_MESSAGE_MAP(SynchronousCompositorBrowserFilter, message) | 54 IPC_BEGIN_MESSAGE_MAP(SynchronousCompositorBrowserFilter, message) |
| 55 IPC_MESSAGE_HANDLER_GENERIC(SyncCompositorHostMsg_ReturnFrame, | 55 IPC_MESSAGE_HANDLER_GENERIC(SyncCompositorHostMsg_ReturnFrame, |
| 56 ReceiveFrame(message)) | 56 ReceiveFrame(message)) |
| 57 IPC_MESSAGE_UNHANDLED(handled = false) | 57 IPC_MESSAGE_UNHANDLED(handled = false) |
| 58 IPC_END_MESSAGE_MAP() | 58 IPC_END_MESSAGE_MAP() |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 base::AutoLock lock(future_map_lock_); | 170 base::AutoLock lock(future_map_lock_); |
| 171 for (auto& pair : future_map_) { | 171 for (auto& pair : future_map_) { |
| 172 for (auto& future_ptr : pair.second) { | 172 for (auto& future_ptr : pair.second) { |
| 173 future_ptr->SetFrame(nullptr); | 173 future_ptr->SetFrame(nullptr); |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 future_map_.clear(); | 176 future_map_.clear(); |
| 177 filter_ready_ = false; | 177 filter_ready_ = false; |
| 178 } | 178 } |
| 179 | 179 |
| 180 void SynchronousCompositorBrowserFilter::OnCompositingDidCommit() { | 180 void SynchronousCompositorBrowserFilter::OnBeginFrame( |
| 181 NOTREACHED(); | 181 const cc::BeginFrameArgs& args) { |
| 182 } | 182 // This is called after DidSendBeginFrame for all SynchronousCompositorHosts |
| 183 | |
| 184 void SynchronousCompositorBrowserFilter::OnRootWindowVisibilityChanged( | |
| 185 bool visible) { | |
| 186 NOTREACHED(); | |
| 187 } | |
| 188 | |
| 189 void SynchronousCompositorBrowserFilter::OnAttachCompositor() { | |
| 190 NOTREACHED(); | |
| 191 } | |
| 192 | |
| 193 void SynchronousCompositorBrowserFilter::OnDetachCompositor() { | |
| 194 NOTREACHED(); | |
| 195 } | |
| 196 | |
| 197 void SynchronousCompositorBrowserFilter::OnVSync(base::TimeTicks frame_time, | |
| 198 base::TimeDelta vsync_period) { | |
| 199 // This is called after DidSendBeginFrame for SynchronousCompositorHosts | |
| 200 // belonging to this WindowAndroid, since this is added as an Observer after | 183 // belonging to this WindowAndroid, since this is added as an Observer after |
| 201 // the observer iteration has started. | 184 // the observer iteration has started. |
| 202 DCHECK(window_android_in_vsync_); | 185 DCHECK(window_android_in_vsync_); |
| 203 window_android_in_vsync_->RemoveObserver(this); | 186 window_android_in_vsync_->GetBeginFrameSource()->RemoveObserver(this); |
| 204 window_android_in_vsync_ = nullptr; | 187 window_android_in_vsync_ = nullptr; |
| 205 | 188 |
| 206 std::vector<int> routing_ids; | 189 std::vector<int> routing_ids; |
| 207 routing_ids.reserve(compositor_host_pending_renderer_state_.size()); | 190 routing_ids.reserve(compositor_host_pending_renderer_state_.size()); |
| 208 for (const auto host : compositor_host_pending_renderer_state_) | 191 for (const auto host : compositor_host_pending_renderer_state_) |
| 209 routing_ids.push_back(host->routing_id()); | 192 routing_ids.push_back(host->routing_id()); |
| 210 | 193 |
| 211 std::vector<SyncCompositorCommonRendererParams> params; | 194 std::vector<SyncCompositorCommonRendererParams> params; |
| 212 params.reserve(compositor_host_pending_renderer_state_.size()); | 195 params.reserve(compositor_host_pending_renderer_state_.size()); |
| 213 | 196 |
| 214 if (!render_process_host_->Send( | 197 if (!render_process_host_->Send( |
| 215 new SyncCompositorMsg_SynchronizeRendererState(routing_ids, | 198 new SyncCompositorMsg_SynchronizeRendererState(routing_ids, |
| 216 ¶ms))) { | 199 ¶ms))) { |
| 217 return; | 200 return; |
| 218 } | 201 } |
| 219 | 202 |
| 220 if (compositor_host_pending_renderer_state_.size() != params.size()) { | 203 if (compositor_host_pending_renderer_state_.size() != params.size()) { |
| 221 bad_message::ReceivedBadMessage(render_process_host_, | 204 bad_message::ReceivedBadMessage(render_process_host_, |
| 222 bad_message::SCO_INVALID_ARGUMENT); | 205 bad_message::SCO_INVALID_ARGUMENT); |
| 223 return; | 206 return; |
| 224 } | 207 } |
| 225 | 208 |
| 226 for (size_t i = 0; i < compositor_host_pending_renderer_state_.size(); ++i) { | 209 for (size_t i = 0; i < compositor_host_pending_renderer_state_.size(); ++i) { |
| 227 compositor_host_pending_renderer_state_[i]->ProcessCommonParams(params[i]); | 210 compositor_host_pending_renderer_state_[i]->ProcessCommonParams(params[i]); |
| 228 } | 211 } |
| 229 compositor_host_pending_renderer_state_.clear(); | 212 compositor_host_pending_renderer_state_.clear(); |
| 230 } | 213 } |
| 231 | 214 |
| 232 void SynchronousCompositorBrowserFilter::OnActivityStopped() { | 215 const cc::BeginFrameArgs& |
| 216 SynchronousCompositorBrowserFilter::LastUsedBeginFrameArgs() const { |
| 217 // Not called by the source since we add and remove ourselves during a single |
| 218 // OnVSync() iteration. |
| 233 NOTREACHED(); | 219 NOTREACHED(); |
| 220 |
| 221 static cc::BeginFrameArgs args; |
| 222 return args; |
| 234 } | 223 } |
| 235 | 224 |
| 236 void SynchronousCompositorBrowserFilter::OnActivityStarted() { | 225 void SynchronousCompositorBrowserFilter::OnBeginFrameSourcePausedChanged( |
| 237 NOTREACHED(); | 226 bool paused) { |
| 227 // The BeginFrameSources we listen to don't use this. |
| 228 DCHECK(!paused); |
| 238 } | 229 } |
| 239 | 230 |
| 240 } // namespace content | 231 } // namespace content |
| OLD | NEW |