| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/android/synchronous_compositor_output_surface.h" | 5 #include "content/renderer/android/synchronous_compositor_output_surface.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 memory_policy_.priority_cutoff_when_visible = | 99 memory_policy_.priority_cutoff_when_visible = |
| 100 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; | 100 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; |
| 101 } | 101 } |
| 102 | 102 |
| 103 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {} | 103 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {} |
| 104 | 104 |
| 105 void SynchronousCompositorOutputSurface::SetSyncClient( | 105 void SynchronousCompositorOutputSurface::SetSyncClient( |
| 106 SynchronousCompositorOutputSurfaceClient* compositor) { | 106 SynchronousCompositorOutputSurfaceClient* compositor) { |
| 107 DCHECK(CalledOnValidThread()); | 107 DCHECK(CalledOnValidThread()); |
| 108 sync_client_ = compositor; | 108 sync_client_ = compositor; |
| 109 if (sync_client_) |
| 110 Send(new SyncCompositorHostMsg_OutputSurfaceCreated(routing_id_)); |
| 109 } | 111 } |
| 110 | 112 |
| 111 bool SynchronousCompositorOutputSurface::OnMessageReceived( | 113 bool SynchronousCompositorOutputSurface::OnMessageReceived( |
| 112 const IPC::Message& message) { | 114 const IPC::Message& message) { |
| 113 bool handled = true; | 115 bool handled = true; |
| 114 IPC_BEGIN_MESSAGE_MAP(SynchronousCompositorOutputSurface, message) | 116 IPC_BEGIN_MESSAGE_MAP(SynchronousCompositorOutputSurface, message) |
| 115 IPC_MESSAGE_HANDLER(SyncCompositorMsg_SetMemoryPolicy, SetMemoryPolicy) | 117 IPC_MESSAGE_HANDLER(SyncCompositorMsg_SetMemoryPolicy, SetMemoryPolicy) |
| 116 IPC_MESSAGE_HANDLER(SyncCompositorMsg_ReclaimResources, OnReclaimResources) | 118 IPC_MESSAGE_HANDLER(SyncCompositorMsg_ReclaimResources, OnReclaimResources) |
| 117 IPC_MESSAGE_UNHANDLED(handled = false) | 119 IPC_MESSAGE_UNHANDLED(handled = false) |
| 118 IPC_END_MESSAGE_MAP() | 120 IPC_END_MESSAGE_MAP() |
| 119 return handled; | 121 return handled; |
| 120 } | 122 } |
| 121 | 123 |
| 122 bool SynchronousCompositorOutputSurface::BindToClient( | 124 bool SynchronousCompositorOutputSurface::BindToClient( |
| 123 cc::OutputSurfaceClient* surface_client) { | 125 cc::OutputSurfaceClient* surface_client) { |
| 124 DCHECK(CalledOnValidThread()); | 126 DCHECK(CalledOnValidThread()); |
| 125 if (!cc::OutputSurface::BindToClient(surface_client)) | 127 if (!cc::OutputSurface::BindToClient(surface_client)) |
| 126 return false; | 128 return false; |
| 127 | 129 |
| 128 client_->SetMemoryPolicy(memory_policy_); | 130 client_->SetMemoryPolicy(memory_policy_); |
| 129 client_->SetTreeActivationCallback( | 131 client_->SetTreeActivationCallback( |
| 130 base::Bind(&SynchronousCompositorOutputSurface::DidActivatePendingTree, | 132 base::Bind(&SynchronousCompositorOutputSurface::DidActivatePendingTree, |
| 131 base::Unretained(this))); | 133 base::Unretained(this))); |
| 132 registry_->RegisterOutputSurface(routing_id_, this); | 134 registry_->RegisterOutputSurface(routing_id_, this); |
| 133 registered_ = true; | 135 registered_ = true; |
| 134 Send(new SyncCompositorHostMsg_OutputSurfaceCreated(routing_id_)); | |
| 135 return true; | 136 return true; |
| 136 } | 137 } |
| 137 | 138 |
| 138 void SynchronousCompositorOutputSurface::DetachFromClient() { | 139 void SynchronousCompositorOutputSurface::DetachFromClient() { |
| 139 DCHECK(CalledOnValidThread()); | 140 DCHECK(CalledOnValidThread()); |
| 140 if (registered_) { | 141 if (registered_) { |
| 141 registry_->UnregisterOutputSurface(routing_id_, this); | 142 registry_->UnregisterOutputSurface(routing_id_, this); |
| 142 } | 143 } |
| 143 client_->SetTreeActivationCallback(base::Closure()); | 144 client_->SetTreeActivationCallback(base::Closure()); |
| 144 cc::OutputSurface::DetachFromClient(); | 145 cc::OutputSurface::DetachFromClient(); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 bool SynchronousCompositorOutputSurface::Send(IPC::Message* message) { | 304 bool SynchronousCompositorOutputSurface::Send(IPC::Message* message) { |
| 304 DCHECK(CalledOnValidThread()); | 305 DCHECK(CalledOnValidThread()); |
| 305 return sender_->Send(message); | 306 return sender_->Send(message); |
| 306 } | 307 } |
| 307 | 308 |
| 308 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 309 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { |
| 309 return thread_checker_.CalledOnValidThread(); | 310 return thread_checker_.CalledOnValidThread(); |
| 310 } | 311 } |
| 311 | 312 |
| 312 } // namespace content | 313 } // namespace content |
| OLD | NEW |