| Index: content/renderer/render_widget.cc
|
| diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
|
| index 5c82eda23832f6bf500bb5cb2975ce53e2c71cbd..a4855d7c707412a3b6be37c4876c387a30048789 100644
|
| --- a/content/renderer/render_widget.cc
|
| +++ b/content/renderer/render_widget.cc
|
| @@ -36,6 +36,7 @@
|
| #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"
|
| @@ -153,6 +154,41 @@ ui::TextInputMode ConvertInputMode(const blink::WebString& input_mode) {
|
| // be spent in input hanlders before input starts getting throttled.
|
| const int kInputHandlingTimeThrottlingThresholdMicroseconds = 4166;
|
|
|
| +class QueueMessageSwapPromise : public cc::SwapPromise {
|
| + public:
|
| + QueueMessageSwapPromise(
|
| + scoped_refptr<IPC::SyncMessageFilter> message_sender,
|
| + scoped_refptr<content::FrameSwapMessageQueue> message_queue,
|
| + IPC::Message* msg)
|
| + : message_sender_(message_sender),
|
| + message_queue_(message_queue),
|
| + msg_(msg) {
|
| + DCHECK(message_sender_.get());
|
| + DCHECK(message_queue_.get());
|
| + DCHECK(msg);
|
| + }
|
| +
|
| + virtual ~QueueMessageSwapPromise() {
|
| + // The promise should have either been kept or broken before it's deleted.
|
| + DCHECK(!msg_);
|
| + }
|
| +
|
| + virtual void DidSwap(cc::CompositorFrameMetadata* metadata) OVERRIDE {
|
| + message_queue_->QueueMessage(msg_);
|
| + msg_ = NULL;
|
| + }
|
| +
|
| + virtual void DidNotSwap(DidNotSwapReason reason) OVERRIDE {
|
| + message_sender_->Send(msg_);
|
| + msg_ = NULL;
|
| + }
|
| +
|
| + private:
|
| + scoped_refptr<IPC::SyncMessageFilter> message_sender_;
|
| + scoped_refptr<content::FrameSwapMessageQueue> message_queue_;
|
| + IPC::Message* msg_;
|
| +};
|
| +
|
| } // namespace
|
|
|
| namespace content {
|
| @@ -397,6 +433,7 @@ RenderWidget::RenderWidget(blink::WebPopupType popup_type,
|
| cached_has_main_frame_vertical_scrollbar_(false),
|
| #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)
|
| @@ -814,7 +851,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
|
|
|
| @@ -837,21 +875,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)) {
|
| @@ -866,21 +905,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 +1247,37 @@ void RenderWidget::DidCommitCompositorFrame() {
|
| DidCommitCompositorFrame());
|
| }
|
|
|
| +namespace {} // namespace
|
| +
|
| +void RenderWidget::QueueMessage(IPC::Message* msg,
|
| + MessageDeliveryPolicy policy) {
|
| + if (!compositor_) {
|
| + Send(msg);
|
| + return;
|
| + }
|
| +
|
| + if (policy == MESSAGE_DELIVERY_POLICY_WITH_NEXT_SWAP) {
|
| + frame_swap_message_queue_->QueueMessage(msg);
|
| + return;
|
| + }
|
| +
|
| + if (policy == MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE &&
|
| + !compositor_->commitRequested()) {
|
| + scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope =
|
| + frame_swap_message_queue_->AcquireSendMessageScope();
|
| + Send(msg);
|
| + return;
|
| + }
|
| +
|
| + DCHECK(policy == MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE ||
|
| + policy == MESSAGE_DELIVERY_POLICY_WITH_NEXT_COMMIT);
|
| + scoped_ptr<cc::SwapPromise> promise(new QueueMessageSwapPromise(
|
| + RenderThreadImpl::current()->sync_message_filter(),
|
| + frame_swap_message_queue_,
|
| + msg));
|
| + compositor_->QueueSwapPromise(promise.Pass());
|
| +}
|
| +
|
| void RenderWidget::didCommitAndDrawCompositorFrame() {
|
| TRACE_EVENT0("gpu", "RenderWidget::didCommitAndDrawCompositorFrame");
|
| // Accelerated FPS tick for performance tests. See
|
|
|