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

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

Issue 1970863002: sync compositor: Memory policy async IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: drop os id 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/common/android/sync_compositor_messages.h"
15 #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"
16 #include "content/renderer/android/synchronous_compositor_filter.h"
16 #include "content/renderer/android/synchronous_compositor_registry.h" 17 #include "content/renderer/android/synchronous_compositor_registry.h"
17 #include "content/renderer/gpu/frame_swap_message_queue.h" 18 #include "content/renderer/gpu/frame_swap_message_queue.h"
19 #include "content/renderer/render_thread_impl.h"
18 #include "gpu/command_buffer/client/context_support.h" 20 #include "gpu/command_buffer/client/context_support.h"
19 #include "gpu/command_buffer/client/gles2_interface.h" 21 #include "gpu/command_buffer/client/gles2_interface.h"
20 #include "gpu/command_buffer/common/gpu_memory_allocation.h" 22 #include "gpu/command_buffer/common/gpu_memory_allocation.h"
21 #include "ipc/ipc_message.h" 23 #include "ipc/ipc_message.h"
22 #include "ipc/ipc_message_macros.h" 24 #include "ipc/ipc_message_macros.h"
25 #include "ipc/ipc_sender.h"
23 #include "third_party/skia/include/core/SkCanvas.h" 26 #include "third_party/skia/include/core/SkCanvas.h"
24 #include "ui/gfx/geometry/rect_conversions.h" 27 #include "ui/gfx/geometry/rect_conversions.h"
25 #include "ui/gfx/skia_util.h" 28 #include "ui/gfx/skia_util.h"
26 #include "ui/gfx/transform.h" 29 #include "ui/gfx/transform.h"
27 30
28 namespace content { 31 namespace content {
29 32
30 namespace { 33 namespace {
31 34
32 const int64_t kFallbackTickTimeoutInMilliseconds = 100; 35 const int64_t kFallbackTickTimeoutInMilliseconds = 100;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 SynchronousCompositorRegistry* registry, 74 SynchronousCompositorRegistry* registry,
72 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue) 75 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue)
73 : cc::OutputSurface( 76 : cc::OutputSurface(
74 context_provider, 77 context_provider,
75 worker_context_provider, 78 worker_context_provider,
76 nullptr, 79 nullptr,
77 std::unique_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))), 80 std::unique_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))),
78 routing_id_(routing_id), 81 routing_id_(routing_id),
79 output_surface_id_(output_surface_id), 82 output_surface_id_(output_surface_id),
80 registry_(registry), 83 registry_(registry),
84 sender_(RenderThreadImpl::current()->sync_compositor_message_filter()),
81 registered_(false), 85 registered_(false),
82 sync_client_(nullptr), 86 sync_client_(nullptr),
83 current_sw_canvas_(nullptr), 87 current_sw_canvas_(nullptr),
84 memory_policy_(0u), 88 memory_policy_(0u),
85 did_swap_(false), 89 did_swap_(false),
86 frame_swap_message_queue_(frame_swap_message_queue), 90 frame_swap_message_queue_(frame_swap_message_queue),
87 fallback_tick_pending_(false), 91 fallback_tick_pending_(false),
88 fallback_tick_running_(false) { 92 fallback_tick_running_(false) {
93 DCHECK(registry_);
94 DCHECK(sender_);
89 thread_checker_.DetachFromThread(); 95 thread_checker_.DetachFromThread();
90 DCHECK(registry_);
91 capabilities_.adjust_deadline_for_parent = false; 96 capabilities_.adjust_deadline_for_parent = false;
92 capabilities_.delegated_rendering = true; 97 capabilities_.delegated_rendering = true;
93 memory_policy_.priority_cutoff_when_visible = 98 memory_policy_.priority_cutoff_when_visible =
94 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; 99 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE;
95 } 100 }
96 101
97 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {} 102 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {}
98 103
99 void SynchronousCompositorOutputSurface::SetSyncClient( 104 void SynchronousCompositorOutputSurface::SetSyncClient(
100 SynchronousCompositorOutputSurfaceClient* compositor) { 105 SynchronousCompositorOutputSurfaceClient* compositor) {
101 DCHECK(CalledOnValidThread()); 106 DCHECK(CalledOnValidThread());
102 sync_client_ = compositor; 107 sync_client_ = compositor;
103 } 108 }
104 109
105 bool SynchronousCompositorOutputSurface::OnMessageReceived( 110 bool SynchronousCompositorOutputSurface::OnMessageReceived(
106 const IPC::Message& message) { 111 const IPC::Message& message) {
107 bool handled = true; 112 bool handled = true;
108 IPC_BEGIN_MESSAGE_MAP(SynchronousCompositorOutputSurface, message) 113 IPC_BEGIN_MESSAGE_MAP(SynchronousCompositorOutputSurface, message)
114 IPC_MESSAGE_HANDLER(SyncCompositorMsg_SetMemoryPolicy, SetMemoryPolicy)
109 IPC_MESSAGE_HANDLER(SyncCompositorMsg_ReclaimResources, OnReclaimResources) 115 IPC_MESSAGE_HANDLER(SyncCompositorMsg_ReclaimResources, OnReclaimResources)
110 IPC_MESSAGE_UNHANDLED(handled = false) 116 IPC_MESSAGE_UNHANDLED(handled = false)
111 IPC_END_MESSAGE_MAP() 117 IPC_END_MESSAGE_MAP()
112 return handled; 118 return handled;
113 } 119 }
114 120
115 bool SynchronousCompositorOutputSurface::BindToClient( 121 bool SynchronousCompositorOutputSurface::BindToClient(
116 cc::OutputSurfaceClient* surface_client) { 122 cc::OutputSurfaceClient* surface_client) {
117 DCHECK(CalledOnValidThread()); 123 DCHECK(CalledOnValidThread());
118 if (!cc::OutputSurface::BindToClient(surface_client)) 124 if (!cc::OutputSurface::BindToClient(surface_client))
119 return false; 125 return false;
120 126
121 client_->SetMemoryPolicy(memory_policy_); 127 client_->SetMemoryPolicy(memory_policy_);
122 registry_->RegisterOutputSurface(routing_id_, this); 128 registry_->RegisterOutputSurface(routing_id_, this);
123 registered_ = true; 129 registered_ = true;
130 Send(new SyncCompositorHostMsg_OutputSurfaceCreated(routing_id_));
124 return true; 131 return true;
125 } 132 }
126 133
127 void SynchronousCompositorOutputSurface::DetachFromClient() { 134 void SynchronousCompositorOutputSurface::DetachFromClient() {
128 DCHECK(CalledOnValidThread()); 135 DCHECK(CalledOnValidThread());
129 if (registered_) { 136 if (registered_) {
130 registry_->UnregisterOutputSurface(routing_id_, this); 137 registry_->UnregisterOutputSurface(routing_id_, this);
131 } 138 }
132 cc::OutputSurface::DetachFromClient(); 139 cc::OutputSurface::DetachFromClient();
133 CancelFallbackTick(); 140 CancelFallbackTick();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 283 }
277 284
278 void SynchronousCompositorOutputSurface::GetMessagesToDeliver( 285 void SynchronousCompositorOutputSurface::GetMessagesToDeliver(
279 std::vector<std::unique_ptr<IPC::Message>>* messages) { 286 std::vector<std::unique_ptr<IPC::Message>>* messages) {
280 DCHECK(CalledOnValidThread()); 287 DCHECK(CalledOnValidThread());
281 std::unique_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope = 288 std::unique_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope =
282 frame_swap_message_queue_->AcquireSendMessageScope(); 289 frame_swap_message_queue_->AcquireSendMessageScope();
283 frame_swap_message_queue_->DrainMessages(messages); 290 frame_swap_message_queue_->DrainMessages(messages);
284 } 291 }
285 292
293 bool SynchronousCompositorOutputSurface::Send(IPC::Message* message) {
hush (inactive) 2016/05/12 19:23:03 why do we need to create a function out of it? why
boliu 2016/05/12 20:16:45 Having a Send method is common pattern in classes
294 DCHECK(CalledOnValidThread());
295 return sender_->Send(message);
296 }
297
286 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { 298 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const {
287 return thread_checker_.CalledOnValidThread(); 299 return thread_checker_.CalledOnValidThread();
288 } 300 }
289 301
290 } // namespace content 302 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698