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

Side by Side Diff: content/renderer/android/synchronous_compositor_output_surface.cc

Issue 1958803003: sync compostor: Return resources async IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 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 "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "cc/output/compositor_frame.h" 10 #include "cc/output/compositor_frame.h"
11 #include "cc/output/context_provider.h" 11 #include "cc/output/context_provider.h"
12 #include "cc/output/output_surface_client.h" 12 #include "cc/output/output_surface_client.h"
13 #include "cc/output/software_output_device.h" 13 #include "cc/output/software_output_device.h"
14 #include "content/common/android/sync_compositor_messages.h"
14 #include "content/renderer/android/synchronous_compositor_external_begin_frame_s ource.h" 15 #include "content/renderer/android/synchronous_compositor_external_begin_frame_s ource.h"
15 #include "content/renderer/android/synchronous_compositor_registry.h" 16 #include "content/renderer/android/synchronous_compositor_registry.h"
16 #include "content/renderer/gpu/frame_swap_message_queue.h" 17 #include "content/renderer/gpu/frame_swap_message_queue.h"
17 #include "gpu/command_buffer/client/context_support.h" 18 #include "gpu/command_buffer/client/context_support.h"
18 #include "gpu/command_buffer/client/gles2_interface.h" 19 #include "gpu/command_buffer/client/gles2_interface.h"
19 #include "gpu/command_buffer/common/gpu_memory_allocation.h" 20 #include "gpu/command_buffer/common/gpu_memory_allocation.h"
21 #include "ipc/ipc_message.h"
22 #include "ipc/ipc_message_macros.h"
20 #include "third_party/skia/include/core/SkCanvas.h" 23 #include "third_party/skia/include/core/SkCanvas.h"
21 #include "ui/gfx/geometry/rect_conversions.h" 24 #include "ui/gfx/geometry/rect_conversions.h"
22 #include "ui/gfx/skia_util.h" 25 #include "ui/gfx/skia_util.h"
23 #include "ui/gfx/transform.h" 26 #include "ui/gfx/transform.h"
24 27
25 namespace content { 28 namespace content {
26 29
27 namespace { 30 namespace {
28 31
29 const int64_t kFallbackTickTimeoutInMilliseconds = 100; 32 const int64_t kFallbackTickTimeoutInMilliseconds = 100;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 95 }
93 96
94 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {} 97 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {}
95 98
96 void SynchronousCompositorOutputSurface::SetSyncClient( 99 void SynchronousCompositorOutputSurface::SetSyncClient(
97 SynchronousCompositorOutputSurfaceClient* compositor) { 100 SynchronousCompositorOutputSurfaceClient* compositor) {
98 DCHECK(CalledOnValidThread()); 101 DCHECK(CalledOnValidThread());
99 sync_client_ = compositor; 102 sync_client_ = compositor;
100 } 103 }
101 104
105 bool SynchronousCompositorOutputSurface::OnMessageReceived(
106 const IPC::Message& message) {
107 bool handled = true;
108 IPC_BEGIN_MESSAGE_MAP(SynchronousCompositorOutputSurface, message)
109 IPC_MESSAGE_HANDLER(SyncCompositorMsg_ReclaimResources, OnReclaimResources)
110 IPC_MESSAGE_UNHANDLED(handled = false)
111 IPC_END_MESSAGE_MAP()
112 return handled;
113 }
114
102 bool SynchronousCompositorOutputSurface::BindToClient( 115 bool SynchronousCompositorOutputSurface::BindToClient(
103 cc::OutputSurfaceClient* surface_client) { 116 cc::OutputSurfaceClient* surface_client) {
104 DCHECK(CalledOnValidThread()); 117 DCHECK(CalledOnValidThread());
105 if (!cc::OutputSurface::BindToClient(surface_client)) 118 if (!cc::OutputSurface::BindToClient(surface_client))
106 return false; 119 return false;
107 120
108 client_->SetMemoryPolicy(memory_policy_); 121 client_->SetMemoryPolicy(memory_policy_);
109 registry_->RegisterOutputSurface(routing_id_, this); 122 registry_->RegisterOutputSurface(routing_id_, this);
110 registered_ = true; 123 registered_ = true;
111 return true; 124 return true;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 bool software_draw) { 230 bool software_draw) {
218 gfx::Transform adjusted_transform = transform; 231 gfx::Transform adjusted_transform = transform;
219 adjusted_transform.matrix().postTranslate(-viewport.x(), -viewport.y(), 0); 232 adjusted_transform.matrix().postTranslate(-viewport.x(), -viewport.y(), 0);
220 did_swap_ = false; 233 did_swap_ = false;
221 client_->OnDraw(adjusted_transform, viewport, clip, software_draw); 234 client_->OnDraw(adjusted_transform, viewport, clip, software_draw);
222 235
223 if (did_swap_) 236 if (did_swap_)
224 client_->DidSwapBuffersComplete(); 237 client_->DidSwapBuffersComplete();
225 } 238 }
226 239
227 void SynchronousCompositorOutputSurface::ReturnResources( 240 void SynchronousCompositorOutputSurface::OnReclaimResources(
228 uint32_t output_surface_id, 241 uint32_t output_surface_id,
229 const cc::CompositorFrameAck& frame_ack) { 242 const cc::CompositorFrameAck& ack) {
230 if (output_surface_id_ == output_surface_id) 243 // Ignore message if it's a stale one coming from a different output surface
231 ReclaimResources(&frame_ack); 244 // (e.g. after a lost context).
245 if (output_surface_id != output_surface_id_)
246 return;
247 ReclaimResources(&ack);
232 } 248 }
233 249
234 void SynchronousCompositorOutputSurface::SetMemoryPolicy(size_t bytes_limit) { 250 void SynchronousCompositorOutputSurface::SetMemoryPolicy(size_t bytes_limit) {
235 DCHECK(CalledOnValidThread()); 251 DCHECK(CalledOnValidThread());
236 bool became_zero = memory_policy_.bytes_limit_when_visible && !bytes_limit; 252 bool became_zero = memory_policy_.bytes_limit_when_visible && !bytes_limit;
237 bool became_non_zero = 253 bool became_non_zero =
238 !memory_policy_.bytes_limit_when_visible && bytes_limit; 254 !memory_policy_.bytes_limit_when_visible && bytes_limit;
239 memory_policy_.bytes_limit_when_visible = bytes_limit; 255 memory_policy_.bytes_limit_when_visible = bytes_limit;
240 memory_policy_.num_resources_limit = kNumResourcesLimit; 256 memory_policy_.num_resources_limit = kNumResourcesLimit;
241 257
(...skipping 23 matching lines...) Expand all
265 std::unique_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope = 281 std::unique_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope =
266 frame_swap_message_queue_->AcquireSendMessageScope(); 282 frame_swap_message_queue_->AcquireSendMessageScope();
267 frame_swap_message_queue_->DrainMessages(messages); 283 frame_swap_message_queue_->DrainMessages(messages);
268 } 284 }
269 285
270 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { 286 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const {
271 return thread_checker_.CalledOnValidThread(); 287 return thread_checker_.CalledOnValidThread();
272 } 288 }
273 289
274 } // namespace content 290 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698