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

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

Issue 2812703003: aw: Remove global AllowWait on UI thread (Closed)
Patch Set: future Created 3 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_host.h" 5 #include "content/browser/android/synchronous_compositor_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/memory/shared_memory.h" 12 #include "base/memory/shared_memory.h"
13 #include "base/threading/thread_restrictions.h"
13 #include "base/trace_event/trace_event_argument.h" 14 #include "base/trace_event/trace_event_argument.h"
14 #include "content/browser/android/synchronous_compositor_browser_filter.h" 15 #include "content/browser/android/synchronous_compositor_browser_filter.h"
15 #include "content/browser/renderer_host/render_widget_host_view_android.h" 16 #include "content/browser/renderer_host/render_widget_host_view_android.h"
16 #include "content/browser/web_contents/web_contents_impl.h" 17 #include "content/browser/web_contents/web_contents_impl.h"
17 #include "content/common/android/sync_compositor_messages.h" 18 #include "content/common/android/sync_compositor_messages.h"
18 #include "content/common/android/sync_compositor_statics.h" 19 #include "content/common/android/sync_compositor_statics.h"
19 #include "content/public/browser/android/synchronous_compositor_client.h" 20 #include "content/public/browser/android/synchronous_compositor_client.h"
20 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
22 #include "content/public/common/content_switches.h" 23 #include "content/public/common/content_switches.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 const gfx::Size& viewport_size, 116 const gfx::Size& viewport_size,
116 const gfx::Rect& viewport_rect_for_tile_priority, 117 const gfx::Rect& viewport_rect_for_tile_priority,
117 const gfx::Transform& transform_for_tile_priority) { 118 const gfx::Transform& transform_for_tile_priority) {
118 SyncCompositorDemandDrawHwParams params(viewport_size, 119 SyncCompositorDemandDrawHwParams params(viewport_size,
119 viewport_rect_for_tile_priority, 120 viewport_rect_for_tile_priority,
120 transform_for_tile_priority); 121 transform_for_tile_priority);
121 uint32_t compositor_frame_sink_id; 122 uint32_t compositor_frame_sink_id;
122 base::Optional<cc::CompositorFrame> compositor_frame; 123 base::Optional<cc::CompositorFrame> compositor_frame;
123 SyncCompositorCommonRendererParams common_renderer_params; 124 SyncCompositorCommonRendererParams common_renderer_params;
124 125
125 if (!sender_->Send(new SyncCompositorMsg_DemandDrawHw( 126 {
126 routing_id_, params, &common_renderer_params, 127 base::ThreadRestrictions::ScopedAllowWait wait;
127 &compositor_frame_sink_id, &compositor_frame))) { 128 if (!sender_->Send(new SyncCompositorMsg_DemandDrawHw(
128 return SynchronousCompositor::Frame(); 129 routing_id_, params, &common_renderer_params,
130 &compositor_frame_sink_id, &compositor_frame))) {
131 return SynchronousCompositor::Frame();
132 }
129 } 133 }
130 134
131 ProcessCommonParams(common_renderer_params); 135 ProcessCommonParams(common_renderer_params);
132 136
133 if (!compositor_frame) 137 if (!compositor_frame)
134 return SynchronousCompositor::Frame(); 138 return SynchronousCompositor::Frame();
135 139
136 SynchronousCompositor::Frame frame; 140 SynchronousCompositor::Frame frame;
137 frame.frame.reset(new cc::CompositorFrame); 141 frame.frame.reset(new cc::CompositorFrame);
138 frame.compositor_frame_sink_id = compositor_frame_sink_id; 142 frame.compositor_frame_sink_id = compositor_frame_sink_id;
(...skipping 30 matching lines...) Expand all
169 }; 173 };
170 174
171 } 175 }
172 176
173 bool SynchronousCompositorHost::DemandDrawSwInProc(SkCanvas* canvas) { 177 bool SynchronousCompositorHost::DemandDrawSwInProc(SkCanvas* canvas) {
174 SyncCompositorCommonRendererParams common_renderer_params; 178 SyncCompositorCommonRendererParams common_renderer_params;
175 bool success = false; 179 bool success = false;
176 std::unique_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); 180 std::unique_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame);
177 ScopedSetSkCanvas set_sk_canvas(canvas); 181 ScopedSetSkCanvas set_sk_canvas(canvas);
178 SyncCompositorDemandDrawSwParams params; // Unused. 182 SyncCompositorDemandDrawSwParams params; // Unused.
179 if (!sender_->Send(new SyncCompositorMsg_DemandDrawSw( 183 {
180 routing_id_, params, &success, &common_renderer_params, 184 base::ThreadRestrictions::ScopedAllowWait wait;
181 frame.get()))) { 185 if (!sender_->Send(new SyncCompositorMsg_DemandDrawSw(
182 return false; 186 routing_id_, params, &success, &common_renderer_params,
187 frame.get()))) {
188 return false;
189 }
183 } 190 }
184 if (!success) 191 if (!success)
185 return false; 192 return false;
186 ProcessCommonParams(common_renderer_params); 193 ProcessCommonParams(common_renderer_params);
187 UpdateFrameMetaData(std::move(frame->metadata)); 194 UpdateFrameMetaData(std::move(frame->metadata));
188 return true; 195 return true;
189 } 196 }
190 197
191 class SynchronousCompositorHost::ScopedSendZeroMemory { 198 class SynchronousCompositorHost::ScopedSendZeroMemory {
192 public: 199 public:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 if (!buffer_size) 239 if (!buffer_size)
233 return false; // Overflow. 240 return false; // Overflow.
234 241
235 SetSoftwareDrawSharedMemoryIfNeeded(stride, buffer_size); 242 SetSoftwareDrawSharedMemoryIfNeeded(stride, buffer_size);
236 if (!software_draw_shm_) 243 if (!software_draw_shm_)
237 return false; 244 return false;
238 245
239 std::unique_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); 246 std::unique_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame);
240 SyncCompositorCommonRendererParams common_renderer_params; 247 SyncCompositorCommonRendererParams common_renderer_params;
241 bool success = false; 248 bool success = false;
242 if (!sender_->Send(new SyncCompositorMsg_DemandDrawSw( 249 {
243 routing_id_, params, &success, &common_renderer_params, 250 base::ThreadRestrictions::ScopedAllowWait wait;
244 frame.get()))) { 251 if (!sender_->Send(new SyncCompositorMsg_DemandDrawSw(
245 return false; 252 routing_id_, params, &success, &common_renderer_params,
253 frame.get()))) {
254 return false;
255 }
246 } 256 }
247 ScopedSendZeroMemory send_zero_memory(this); 257 ScopedSendZeroMemory send_zero_memory(this);
248 if (!success) 258 if (!success)
249 return false; 259 return false;
250 260
251 ProcessCommonParams(common_renderer_params); 261 ProcessCommonParams(common_renderer_params);
252 UpdateFrameMetaData(std::move(frame->metadata)); 262 UpdateFrameMetaData(std::move(frame->metadata));
253 263
254 SkBitmap bitmap; 264 SkBitmap bitmap;
255 if (!bitmap.installPixels(info, software_draw_shm_->shm.memory(), stride)) 265 if (!bitmap.installPixels(info, software_draw_shm_->shm.memory(), stride))
(...skipping 29 matching lines...) Expand all
285 set_shm_params.buffer_size = buffer_size; 295 set_shm_params.buffer_size = buffer_size;
286 base::ProcessHandle renderer_process_handle = 296 base::ProcessHandle renderer_process_handle =
287 rwhva_->GetRenderWidgetHost()->GetProcess()->GetHandle(); 297 rwhva_->GetRenderWidgetHost()->GetProcess()->GetHandle();
288 if (!software_draw_shm->shm.ShareToProcess(renderer_process_handle, 298 if (!software_draw_shm->shm.ShareToProcess(renderer_process_handle,
289 &set_shm_params.shm_handle)) { 299 &set_shm_params.shm_handle)) {
290 return; 300 return;
291 } 301 }
292 302
293 bool success = false; 303 bool success = false;
294 SyncCompositorCommonRendererParams common_renderer_params; 304 SyncCompositorCommonRendererParams common_renderer_params;
295 if (!sender_->Send(new SyncCompositorMsg_SetSharedMemory( 305 {
296 routing_id_, set_shm_params, &success, &common_renderer_params)) || 306 base::ThreadRestrictions::ScopedAllowWait wait;
297 !success) { 307 if (!sender_->Send(new SyncCompositorMsg_SetSharedMemory(
298 return; 308 routing_id_, set_shm_params, &success, &common_renderer_params)) ||
309 !success) {
310 return;
311 }
299 } 312 }
300 software_draw_shm_ = std::move(software_draw_shm); 313 software_draw_shm_ = std::move(software_draw_shm);
301 ProcessCommonParams(common_renderer_params); 314 ProcessCommonParams(common_renderer_params);
302 } 315 }
303 316
304 void SynchronousCompositorHost::SendZeroMemory() { 317 void SynchronousCompositorHost::SendZeroMemory() {
305 // No need to check return value. 318 // No need to check return value.
306 sender_->Send(new SyncCompositorMsg_ZeroSharedMemory(routing_id_)); 319 sender_->Send(new SyncCompositorMsg_ZeroSharedMemory(routing_id_));
307 } 320 }
308 321
(...skipping 20 matching lines...) Expand all
329 if (root_scroll_offset_ == root_offset) 342 if (root_scroll_offset_ == root_offset)
330 return; 343 return;
331 root_scroll_offset_ = root_offset; 344 root_scroll_offset_ = root_offset;
332 sender_->Send( 345 sender_->Send(
333 new SyncCompositorMsg_SetScroll(routing_id_, root_scroll_offset_)); 346 new SyncCompositorMsg_SetScroll(routing_id_, root_scroll_offset_));
334 } 347 }
335 348
336 void SynchronousCompositorHost::SynchronouslyZoomBy(float zoom_delta, 349 void SynchronousCompositorHost::SynchronouslyZoomBy(float zoom_delta,
337 const gfx::Point& anchor) { 350 const gfx::Point& anchor) {
338 SyncCompositorCommonRendererParams common_renderer_params; 351 SyncCompositorCommonRendererParams common_renderer_params;
339 if (!sender_->Send(new SyncCompositorMsg_ZoomBy( 352 {
340 routing_id_, zoom_delta, anchor, &common_renderer_params))) { 353 base::ThreadRestrictions::ScopedAllowWait wait;
341 return; 354 if (!sender_->Send(new SyncCompositorMsg_ZoomBy(
355 routing_id_, zoom_delta, anchor, &common_renderer_params))) {
356 return;
357 }
342 } 358 }
343 ProcessCommonParams(common_renderer_params); 359 ProcessCommonParams(common_renderer_params);
344 } 360 }
345 361
346 void SynchronousCompositorHost::OnComputeScroll( 362 void SynchronousCompositorHost::OnComputeScroll(
347 base::TimeTicks animation_time) { 363 base::TimeTicks animation_time) {
348 if (!need_animate_scroll_) 364 if (!need_animate_scroll_)
349 return; 365 return;
350 need_animate_scroll_ = false; 366 need_animate_scroll_ = false;
351 367
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 if (params.page_scale_factor) { 420 if (params.page_scale_factor) {
405 client_->UpdateRootLayerState( 421 client_->UpdateRootLayerState(
406 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), 422 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset),
407 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), 423 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset),
408 params.scrollable_size, params.page_scale_factor, 424 params.scrollable_size, params.page_scale_factor,
409 params.min_page_scale_factor, params.max_page_scale_factor); 425 params.min_page_scale_factor, params.max_page_scale_factor);
410 } 426 }
411 } 427 }
412 428
413 } // namespace content 429 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698