Chromium Code Reviews| Index: content/renderer/render_widget.cc |
| diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc |
| index 38af2733ce4e524c3a69c8611688874eb00d1adc..dcd8214b7f06c48b087eb7cb9d806650d03c8244 100644 |
| --- a/content/renderer/render_widget.cc |
| +++ b/content/renderer/render_widget.cc |
| @@ -37,11 +37,13 @@ |
| #include "content/renderer/gpu/compositor_output_surface.h" |
| #include "content/renderer/gpu/compositor_software_output_device.h" |
| #include "content/renderer/gpu/delegated_compositor_output_surface.h" |
| +#include "content/renderer/gpu/frame_swap_message_queue.h" |
| #include "content/renderer/gpu/mailbox_output_surface.h" |
| #include "content/renderer/gpu/render_widget_compositor.h" |
| #include "content/renderer/ime_event_guard.h" |
| #include "content/renderer/input/input_handler_manager.h" |
| #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| +#include "content/renderer/queue_message_swap_promise.h" |
| #include "content/renderer/render_frame_impl.h" |
| #include "content/renderer/render_frame_proxy.h" |
| #include "content/renderer/render_process.h" |
| @@ -396,6 +398,7 @@ RenderWidget::RenderWidget(blink::WebPopupType popup_type, |
| body_background_color_(SK_ColorWHITE), |
| #endif |
| popup_origin_scale_for_emulation_(0.f), |
| + frame_swap_message_queue_(new FrameSwapMessageQueue()), |
| resizing_mode_selector_(new ResizingModeSelector()), |
| context_menu_source_type_(ui::MENU_SOURCE_MOUSE) { |
| if (!swapped_out) |
| @@ -811,7 +814,8 @@ scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) { |
| #if defined(OS_ANDROID) |
| if (SynchronousCompositorFactory* factory = |
| SynchronousCompositorFactory::GetInstance()) { |
| - return factory->CreateOutputSurface(routing_id()); |
| + return factory->CreateOutputSurface(routing_id(), |
| + frame_swap_message_queue_); |
| } |
| #endif |
| @@ -834,21 +838,22 @@ scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) { |
| if (command_line.HasSwitch(switches::kEnableDelegatedRenderer)) { |
| DCHECK(is_threaded_compositing_enabled_); |
| return scoped_ptr<cc::OutputSurface>( |
| - new DelegatedCompositorOutputSurface( |
| - routing_id(), |
| - output_surface_id, |
| - context_provider)); |
| + new DelegatedCompositorOutputSurface(routing_id(), |
| + output_surface_id, |
| + context_provider, |
| + frame_swap_message_queue_)); |
| } |
| if (!context_provider.get()) { |
| scoped_ptr<cc::SoftwareOutputDevice> software_device( |
| new CompositorSoftwareOutputDevice()); |
| - return scoped_ptr<cc::OutputSurface>(new CompositorOutputSurface( |
| - routing_id(), |
| - output_surface_id, |
| - NULL, |
| - software_device.Pass(), |
| - true)); |
| + return scoped_ptr<cc::OutputSurface>( |
| + new CompositorOutputSurface(routing_id(), |
| + output_surface_id, |
| + NULL, |
| + software_device.Pass(), |
| + frame_swap_message_queue_, |
| + true)); |
| } |
| if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { |
| @@ -863,21 +868,21 @@ scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) { |
| format = cc::RGB_565; |
| #endif |
| return scoped_ptr<cc::OutputSurface>( |
| - new MailboxOutputSurface( |
| - routing_id(), |
| - output_surface_id, |
| - context_provider, |
| - scoped_ptr<cc::SoftwareOutputDevice>(), |
| - format)); |
| + new MailboxOutputSurface(routing_id(), |
| + output_surface_id, |
| + context_provider, |
| + scoped_ptr<cc::SoftwareOutputDevice>(), |
| + frame_swap_message_queue_, |
| + format)); |
| } |
| bool use_swap_compositor_frame_message = false; |
| return scoped_ptr<cc::OutputSurface>( |
| - new CompositorOutputSurface( |
| - routing_id(), |
| - output_surface_id, |
| - context_provider, |
| - scoped_ptr<cc::SoftwareOutputDevice>(), |
| - use_swap_compositor_frame_message)); |
| + new CompositorOutputSurface(routing_id(), |
| + output_surface_id, |
| + context_provider, |
| + scoped_ptr<cc::SoftwareOutputDevice>(), |
| + frame_swap_message_queue_, |
| + use_swap_compositor_frame_message)); |
| } |
| void RenderWidget::OnSwapBuffersAborted() { |
| @@ -1208,6 +1213,66 @@ void RenderWidget::DidCommitCompositorFrame() { |
| #endif // defined(VIDEO_HOLE) |
| } |
| +// static |
| +scoped_ptr<cc::SwapPromise> RenderWidget::QueueMessageImpl( |
| + IPC::Message* msg, |
| + MessageDeliveryPolicy policy, |
| + FrameSwapMessageQueue* frame_swap_message_queue, |
| + scoped_refptr<IPC::SyncMessageFilter> sync_message_filter, |
| + bool commit_requested, |
| + int source_frame_number) { |
| + if (policy == MESSAGE_DELIVERY_POLICY_WITH_NEXT_SWAP) { |
| + frame_swap_message_queue->QueueMessage(make_scoped_ptr(msg)); |
| + // TODO: do we want to SetNeedsRedraw here? |
|
mkosiba (inactive)
2014/06/24 18:29:54
do we?
piman
2014/06/24 19:35:53
It's hard to tell with no caller yet.
Maybe it's b
mkosiba (inactive)
2014/06/25 18:40:38
ack.
|
| + return scoped_ptr<cc::SwapPromise>(); |
| + } |
| + |
| + if (policy == MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE && |
| + // No need for lock: this gets changed only on this thread. |
| + !commit_requested && |
| + // No need for lock: Messages are only enqueued from this thread, if we |
| + // don't have any now, no other thread will add any. |
| + frame_swap_message_queue->Empty()) { |
| + sync_message_filter->Send(msg); |
| + return scoped_ptr<cc::SwapPromise>(); |
| + } |
| + |
| + DCHECK(policy == MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE || |
| + policy == MESSAGE_DELIVERY_POLICY_WITH_NEXT_COMMIT); |
| + bool first_message_for_frame = false; |
| + frame_swap_message_queue->QueueMessageForFrame( |
| + source_frame_number, make_scoped_ptr(msg), &first_message_for_frame); |
| + if (first_message_for_frame) { |
| + scoped_ptr<cc::SwapPromise> promise(new QueueMessageSwapPromise( |
| + sync_message_filter, |
| + frame_swap_message_queue, |
| + source_frame_number)); |
| + return promise.PassAs<cc::SwapPromise>(); |
| + } |
| + return scoped_ptr<cc::SwapPromise>(); |
| +} |
| + |
| +void RenderWidget::QueueMessage(IPC::Message* msg, |
| + MessageDeliveryPolicy policy) { |
| + if (!compositor_) { |
| + Send(msg); |
| + return; |
| + } |
| + |
| + scoped_ptr<cc::SwapPromise> swap_promise = |
| + QueueMessageImpl(msg, |
| + policy, |
| + frame_swap_message_queue_, |
| + RenderThreadImpl::current()->sync_message_filter(), |
| + !compositor_->commitRequested(), |
|
piman
2014/06/24 19:35:53
no ! I think?
mkosiba (inactive)
2014/06/25 18:40:38
right, copy-paste is the most evil thing ever.
|
| + compositor_->GetSourceFrameNumber()); |
| + |
| + if (swap_promise) { |
| + compositor_->QueueSwapPromise(swap_promise.Pass()); |
| + compositor_->setNeedsCommit(); |
| + } |
| +} |
| + |
| void RenderWidget::didCommitAndDrawCompositorFrame() { |
| // NOTE: Tests may break if this event is renamed or moved. See |
| // tab_capture_performancetest.cc. |