Commit 40b2fccf authored by fsamuel's avatar fsamuel Committed by Commit bot

RenderWidgetCompositor should be decoupled from RenderWidget.

This is a mechanical refactor of RenderWidgetCompositor and
RenderWidget. At this point it removes references for
routing ID, and RenderWidget from RenderWidgetCompositor's
implementation. This is likely not the final refactor as I
am still in the process of detangling WebWidgetClient's
implementation from RenderWidget. Once that happens, I
might have some simplifications.

BUG=577321

Review URL: https://codereview.chromium.org/1587743002

Cr-Commit-Position: refs/heads/master@{#369383}
parent aadf6d08
...@@ -215,6 +215,7 @@ ...@@ -215,6 +215,7 @@
'renderer/gpu/queue_message_swap_promise.h', 'renderer/gpu/queue_message_swap_promise.h',
'renderer/gpu/render_widget_compositor.cc', 'renderer/gpu/render_widget_compositor.cc',
'renderer/gpu/render_widget_compositor.h', 'renderer/gpu/render_widget_compositor.h',
'renderer/gpu/render_widget_compositor_delegate.h',
'renderer/gpu/stream_texture_host_android.cc', 'renderer/gpu/stream_texture_host_android.cc',
'renderer/gpu/stream_texture_host_android.h', 'renderer/gpu/stream_texture_host_android.h',
'renderer/history_controller.cc', 'renderer/history_controller.cc',
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "content/common/content_switches_internal.h" #include "content/common/content_switches_internal.h"
#include "content/common/gpu/client/context_provider_command_buffer.h" #include "content/common/gpu/client/context_provider_command_buffer.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/renderer/gpu/render_widget_compositor_delegate.h"
#include "content/renderer/input/input_handler_manager.h" #include "content/renderer/input/input_handler_manager.h"
#include "gpu/command_buffer/client/gles2_interface.h" #include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/service/gpu_switches.h" #include "gpu/command_buffer/service/gpu_switches.h"
...@@ -54,7 +55,6 @@ ...@@ -54,7 +55,6 @@
#include "third_party/WebKit/public/web/WebKit.h" #include "third_party/WebKit/public/web/WebKit.h"
#include "third_party/WebKit/public/web/WebRuntimeFeatures.h" #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
#include "third_party/WebKit/public/web/WebSelection.h" #include "third_party/WebKit/public/web/WebSelection.h"
#include "third_party/WebKit/public/web/WebWidget.h"
#include "ui/gl/gl_switches.h" #include "ui/gl/gl_switches.h"
#include "ui/native_theme/native_theme_switches.h" #include "ui/native_theme/native_theme_switches.h"
...@@ -135,7 +135,7 @@ cc::LayerSelection ConvertWebSelection(const WebSelection& web_selection) { ...@@ -135,7 +135,7 @@ cc::LayerSelection ConvertWebSelection(const WebSelection& web_selection) {
return cc_selection; return cc_selection;
} }
gfx::Size CalculateDefaultTileSize(RenderWidget* widget) { gfx::Size CalculateDefaultTileSize(float initial_device_scale_factor) {
int default_tile_size = 256; int default_tile_size = 256;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// TODO(epenner): unify this for all platforms if it // TODO(epenner): unify this for all platforms if it
...@@ -180,7 +180,7 @@ gfx::Size CalculateDefaultTileSize(RenderWidget* widget) { ...@@ -180,7 +180,7 @@ gfx::Size CalculateDefaultTileSize(RenderWidget* widget) {
} }
#elif defined(OS_CHROMEOS) #elif defined(OS_CHROMEOS)
// Use 512 for high DPI (dsf=2.0f) devices. // Use 512 for high DPI (dsf=2.0f) devices.
if (widget->screen_info().deviceScaleFactor >= 2.0f) if (initial_device_scale_factor >= 2.0f)
default_tile_size = 512; default_tile_size = 512;
#endif #endif
...@@ -205,27 +205,27 @@ static cc::TopControlsState ConvertTopControlsState( ...@@ -205,27 +205,27 @@ static cc::TopControlsState ConvertTopControlsState(
// static // static
scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create( scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create(
RenderWidget* widget, RenderWidgetCompositorDelegate* delegate,
float device_scale_factor,
CompositorDependencies* compositor_deps) { CompositorDependencies* compositor_deps) {
scoped_ptr<RenderWidgetCompositor> compositor( scoped_ptr<RenderWidgetCompositor> compositor(
new RenderWidgetCompositor(widget, compositor_deps)); new RenderWidgetCompositor(delegate, compositor_deps));
compositor->Initialize(); compositor->Initialize(device_scale_factor);
return compositor; return compositor;
} }
RenderWidgetCompositor::RenderWidgetCompositor( RenderWidgetCompositor::RenderWidgetCompositor(
RenderWidget* widget, RenderWidgetCompositorDelegate* delegate,
CompositorDependencies* compositor_deps) CompositorDependencies* compositor_deps)
: num_failed_recreate_attempts_(0), : num_failed_recreate_attempts_(0),
widget_(widget), delegate_(delegate),
compositor_deps_(compositor_deps), compositor_deps_(compositor_deps),
never_visible_(false), never_visible_(false),
layout_and_paint_async_callback_(nullptr), layout_and_paint_async_callback_(nullptr),
remote_proto_channel_receiver_(nullptr), remote_proto_channel_receiver_(nullptr),
weak_factory_(this) { weak_factory_(this) {}
}
void RenderWidgetCompositor::Initialize() { void RenderWidgetCompositor::Initialize(float device_scale_factor) {
base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
cc::LayerTreeSettings settings; cc::LayerTreeSettings settings;
...@@ -257,7 +257,7 @@ void RenderWidgetCompositor::Initialize() { ...@@ -257,7 +257,7 @@ void RenderWidgetCompositor::Initialize() {
blink::WebRuntimeFeatures::enableCompositorAnimationTimelines( blink::WebRuntimeFeatures::enableCompositorAnimationTimelines(
settings.use_compositor_animation_timelines); settings.use_compositor_animation_timelines);
settings.default_tile_size = CalculateDefaultTileSize(widget_); settings.default_tile_size = CalculateDefaultTileSize(device_scale_factor);
if (cmd->HasSwitch(switches::kDefaultTileWidth)) { if (cmd->HasSwitch(switches::kDefaultTileWidth)) {
int tile_width = 0; int tile_width = 0;
GetSwitchValueAsInt(*cmd, GetSwitchValueAsInt(*cmd,
...@@ -456,7 +456,7 @@ void RenderWidgetCompositor::Initialize() { ...@@ -456,7 +456,7 @@ void RenderWidgetCompositor::Initialize() {
settings.renderer_settings.use_rgba_4444_textures &= settings.renderer_settings.use_rgba_4444_textures &=
!cmd->HasSwitch(switches::kDisableRGBA4444Textures); !cmd->HasSwitch(switches::kDisableRGBA4444Textures);
if (widget_->for_oopif()) { if (delegate_->ForOOPIF()) {
// TODO(simonhong): Apply BeginFrame scheduling for OOPIF. // TODO(simonhong): Apply BeginFrame scheduling for OOPIF.
// See crbug.com/471411. // See crbug.com/471411.
settings.use_external_begin_frame_source = false; settings.use_external_begin_frame_source = false;
...@@ -489,8 +489,7 @@ void RenderWidgetCompositor::Initialize() { ...@@ -489,8 +489,7 @@ void RenderWidgetCompositor::Initialize() {
scoped_ptr<cc::BeginFrameSource> external_begin_frame_source; scoped_ptr<cc::BeginFrameSource> external_begin_frame_source;
if (settings.use_external_begin_frame_source) { if (settings.use_external_begin_frame_source) {
external_begin_frame_source = external_begin_frame_source = delegate_->CreateExternalBeginFrameSource();
compositor_deps_->CreateExternalBeginFrameSource(widget_->routing_id());
} }
cc::LayerTreeHost::InitParams params; cc::LayerTreeHost::InitParams params;
...@@ -865,7 +864,7 @@ void RenderWidgetCompositor::setTopControlsShownRatio(float ratio) { ...@@ -865,7 +864,7 @@ void RenderWidgetCompositor::setTopControlsShownRatio(float ratio) {
} }
void RenderWidgetCompositor::WillBeginMainFrame() { void RenderWidgetCompositor::WillBeginMainFrame() {
widget_->WillBeginCompositorFrame(); delegate_->WillBeginCompositorFrame();
} }
void RenderWidgetCompositor::DidBeginMainFrame() { void RenderWidgetCompositor::DidBeginMainFrame() {
...@@ -874,7 +873,7 @@ void RenderWidgetCompositor::DidBeginMainFrame() { ...@@ -874,7 +873,7 @@ void RenderWidgetCompositor::DidBeginMainFrame() {
void RenderWidgetCompositor::BeginMainFrame(const cc::BeginFrameArgs& args) { void RenderWidgetCompositor::BeginMainFrame(const cc::BeginFrameArgs& args) {
compositor_deps_->GetRendererScheduler()->WillBeginFrame(args); compositor_deps_->GetRendererScheduler()->WillBeginFrame(args);
double frame_time_sec = (args.frame_time - base::TimeTicks()).InSecondsF(); double frame_time_sec = (args.frame_time - base::TimeTicks()).InSecondsF();
widget_->webwidget()->beginFrame(frame_time_sec); delegate_->BeginMainFrame(frame_time_sec);
} }
void RenderWidgetCompositor::BeginMainFrameNotExpectedSoon() { void RenderWidgetCompositor::BeginMainFrameNotExpectedSoon() {
...@@ -882,8 +881,7 @@ void RenderWidgetCompositor::BeginMainFrameNotExpectedSoon() { ...@@ -882,8 +881,7 @@ void RenderWidgetCompositor::BeginMainFrameNotExpectedSoon() {
} }
void RenderWidgetCompositor::UpdateLayerTreeHost() { void RenderWidgetCompositor::UpdateLayerTreeHost() {
widget_->webwidget()->updateAllLifecyclePhases(); delegate_->UpdateVisualState();
if (temporary_copy_output_request_) { if (temporary_copy_output_request_) {
// For WebViewImpl, this will always have a root layer. For other widgets, // For WebViewImpl, this will always have a root layer. For other widgets,
// the widget may be closed before servicing this request, so ignore it. // the widget may be closed before servicing this request, so ignore it.
...@@ -903,24 +901,16 @@ void RenderWidgetCompositor::ApplyViewportDeltas( ...@@ -903,24 +901,16 @@ void RenderWidgetCompositor::ApplyViewportDeltas(
const gfx::Vector2dF& elastic_overscroll_delta, const gfx::Vector2dF& elastic_overscroll_delta,
float page_scale, float page_scale,
float top_controls_delta) { float top_controls_delta) {
widget_->webwidget()->applyViewportDeltas( delegate_->ApplyViewportDeltas(inner_delta, outer_delta,
inner_delta, elastic_overscroll_delta, page_scale,
outer_delta, top_controls_delta);
elastic_overscroll_delta,
page_scale,
top_controls_delta);
} }
void RenderWidgetCompositor::RequestNewOutputSurface() { void RenderWidgetCompositor::RequestNewOutputSurface() {
// If the host is closing, then no more compositing is possible. This
// prevents shutdown races between handling the close message and
// the CreateOutputSurface task.
if (widget_->host_closing())
return;
bool fallback = bool fallback =
num_failed_recreate_attempts_ >= OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK; num_failed_recreate_attempts_ >= OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK;
scoped_ptr<cc::OutputSurface> surface(widget_->CreateOutputSurface(fallback)); scoped_ptr<cc::OutputSurface> surface(
delegate_->CreateOutputSurface(fallback));
if (!surface) { if (!surface) {
DidFailToInitializeOutputSurface(); DidFailToInitializeOutputSurface();
...@@ -954,35 +944,35 @@ void RenderWidgetCompositor::WillCommit() { ...@@ -954,35 +944,35 @@ void RenderWidgetCompositor::WillCommit() {
void RenderWidgetCompositor::DidCommit() { void RenderWidgetCompositor::DidCommit() {
DCHECK(!temporary_copy_output_request_); DCHECK(!temporary_copy_output_request_);
widget_->DidCommitCompositorFrame(); delegate_->DidCommitCompositorFrame();
compositor_deps_->GetRendererScheduler()->DidCommitFrameToCompositor(); compositor_deps_->GetRendererScheduler()->DidCommitFrameToCompositor();
} }
void RenderWidgetCompositor::DidCommitAndDrawFrame() { void RenderWidgetCompositor::DidCommitAndDrawFrame() {
widget_->DidCommitAndDrawCompositorFrame(); delegate_->DidCommitAndDrawCompositorFrame();
} }
void RenderWidgetCompositor::DidCompleteSwapBuffers() { void RenderWidgetCompositor::DidCompleteSwapBuffers() {
widget_->DidCompleteSwapBuffers(); delegate_->DidCompleteSwapBuffers();
bool threaded = !!compositor_deps_->GetCompositorImplThreadTaskRunner().get(); bool threaded = !!compositor_deps_->GetCompositorImplThreadTaskRunner().get();
if (!threaded) if (!threaded)
widget_->OnSwapBuffersComplete(); delegate_->OnSwapBuffersComplete();
} }
void RenderWidgetCompositor::DidCompletePageScaleAnimation() { void RenderWidgetCompositor::DidCompletePageScaleAnimation() {
widget_->DidCompletePageScaleAnimation(); delegate_->DidCompletePageScaleAnimation();
} }
void RenderWidgetCompositor::ScheduleAnimation() { void RenderWidgetCompositor::ScheduleAnimation() {
widget_->scheduleAnimation(); delegate_->ScheduleAnimation();
} }
void RenderWidgetCompositor::DidPostSwapBuffers() { void RenderWidgetCompositor::DidPostSwapBuffers() {
widget_->OnSwapBuffersPosted(); delegate_->OnSwapBuffersPosted();
} }
void RenderWidgetCompositor::DidAbortSwapBuffers() { void RenderWidgetCompositor::DidAbortSwapBuffers() {
widget_->OnSwapBuffersAborted(); delegate_->OnSwapBuffersAborted();
} }
void RenderWidgetCompositor::SetProtoReceiver(ProtoReceiver* receiver) { void RenderWidgetCompositor::SetProtoReceiver(ProtoReceiver* receiver) {
...@@ -995,39 +985,14 @@ void RenderWidgetCompositor::SendCompositorProto( ...@@ -995,39 +985,14 @@ void RenderWidgetCompositor::SendCompositorProto(
size_t unsigned_size = base::checked_cast<size_t>(signed_size); size_t unsigned_size = base::checked_cast<size_t>(signed_size);
std::vector<uint8_t> serialized(unsigned_size); std::vector<uint8_t> serialized(unsigned_size);
proto.SerializeToArray(serialized.data(), signed_size); proto.SerializeToArray(serialized.data(), signed_size);
widget_->ForwardCompositorProto(serialized); delegate_->ForwardCompositorProto(serialized);
} }
void RenderWidgetCompositor::RecordFrameTimingEvents( void RenderWidgetCompositor::RecordFrameTimingEvents(
scoped_ptr<cc::FrameTimingTracker::CompositeTimingSet> composite_events, scoped_ptr<cc::FrameTimingTracker::CompositeTimingSet> composite_events,
scoped_ptr<cc::FrameTimingTracker::MainFrameTimingSet> main_frame_events) { scoped_ptr<cc::FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
for (const auto& composite_event : *composite_events ) { delegate_->RecordFrameTimingEvents(std::move(composite_events),
int64_t frameId = composite_event.first; std::move(main_frame_events));
const std::vector<cc::FrameTimingTracker::CompositeTimingEvent>& events =
composite_event.second;
std::vector<blink::WebFrameTimingEvent> webEvents;
for (size_t i = 0; i < events.size(); ++i) {
webEvents.push_back(blink::WebFrameTimingEvent(
events[i].frame_id,
(events[i].timestamp - base::TimeTicks()).InSecondsF()));
}
widget_->webwidget()->recordFrameTimingEvent(
blink::WebWidget::CompositeEvent, frameId, webEvents);
}
for (const auto& main_frame_event : *main_frame_events ) {
int64_t frameId = main_frame_event.first;
const std::vector<cc::FrameTimingTracker::MainFrameTimingEvent>& events =
main_frame_event.second;
std::vector<blink::WebFrameTimingEvent> webEvents;
for (size_t i = 0; i < events.size(); ++i) {
webEvents.push_back(blink::WebFrameTimingEvent(
events[i].frame_id,
(events[i].timestamp - base::TimeTicks()).InSecondsF(),
(events[i].end_time - base::TimeTicks()).InSecondsF()));
}
widget_->webwidget()->recordFrameTimingEvent(
blink::WebWidget::RenderEvent, frameId, webEvents);
}
} }
void RenderWidgetCompositor::SetSurfaceIdNamespace( void RenderWidgetCompositor::SetSurfaceIdNamespace(
......
...@@ -42,7 +42,8 @@ class CompositorMessage; ...@@ -42,7 +42,8 @@ class CompositorMessage;
} }
namespace content { namespace content {
class RenderWidget;
class RenderWidgetCompositorDelegate;
class CONTENT_EXPORT RenderWidgetCompositor class CONTENT_EXPORT RenderWidgetCompositor
: NON_EXPORTED_BASE(public blink::WebLayerTreeView), : NON_EXPORTED_BASE(public blink::WebLayerTreeView),
...@@ -53,7 +54,8 @@ class CONTENT_EXPORT RenderWidgetCompositor ...@@ -53,7 +54,8 @@ class CONTENT_EXPORT RenderWidgetCompositor
// Attempt to construct and initialize a compositor instance for the widget // Attempt to construct and initialize a compositor instance for the widget
// with the given settings. Returns NULL if initialization fails. // with the given settings. Returns NULL if initialization fails.
static scoped_ptr<RenderWidgetCompositor> Create( static scoped_ptr<RenderWidgetCompositor> Create(
RenderWidget* widget, RenderWidgetCompositorDelegate* delegate,
float device_scale_factor,
CompositorDependencies* compositor_deps); CompositorDependencies* compositor_deps);
~RenderWidgetCompositor() override; ~RenderWidgetCompositor() override;
...@@ -184,10 +186,10 @@ class CONTENT_EXPORT RenderWidgetCompositor ...@@ -184,10 +186,10 @@ class CONTENT_EXPORT RenderWidgetCompositor
}; };
protected: protected:
RenderWidgetCompositor(RenderWidget* widget, RenderWidgetCompositor(RenderWidgetCompositorDelegate* delegate,
CompositorDependencies* compositor_deps); CompositorDependencies* compositor_deps);
void Initialize(); void Initialize(float device_scale_factor);
cc::LayerTreeHost* layer_tree_host() { return layer_tree_host_.get(); } cc::LayerTreeHost* layer_tree_host() { return layer_tree_host_.get(); }
private: private:
...@@ -197,8 +199,8 @@ class CONTENT_EXPORT RenderWidgetCompositor ...@@ -197,8 +199,8 @@ class CONTENT_EXPORT RenderWidgetCompositor
void SynchronouslyComposite(); void SynchronouslyComposite();
int num_failed_recreate_attempts_; int num_failed_recreate_attempts_;
RenderWidget* widget_; RenderWidgetCompositorDelegate* const delegate_;
CompositorDependencies* compositor_deps_; CompositorDependencies* const compositor_deps_;
scoped_ptr<cc::LayerTreeHost> layer_tree_host_; scoped_ptr<cc::LayerTreeHost> layer_tree_host_;
bool never_visible_; bool never_visible_;
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_DELEGATE_H_
#define CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_DELEGATE_H_
#include "cc/debug/frame_timing_tracker.h"
namespace blink {
class WebWidget;
struct WebScreenInfo;
}
namespace cc {
class BeginFrameSource;
class OutputSurface;
}
namespace content {
// Consumers of RenderWidgetCompositor implement this delegate in order to
// transport compositing information across processes.
class CONTENT_EXPORT RenderWidgetCompositorDelegate {
public:
// Report viewport related properties during a commit from the compositor
// thread.
virtual void ApplyViewportDeltas(
const gfx::Vector2dF& inner_delta,
const gfx::Vector2dF& outer_delta,
const gfx::Vector2dF& elastic_overscroll_delta,
float page_scale,
float top_controls_delta) = 0;
// Notifies that the compositor has issed a BeginMainFrame.
virtual void BeginMainFrame(double frame_time_sec) = 0;
// Requests an OutputSurface to render into.
virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) = 0;
// Requests an external BeginFrameSource from the delegate.
virtual scoped_ptr<cc::BeginFrameSource> CreateExternalBeginFrameSource() = 0;
// Notifies that the draw commands for a committed frame have been issued.
virtual void DidCommitAndDrawCompositorFrame() = 0;
// Notifies about a compositor frame commit operation having finished.
virtual void DidCommitCompositorFrame() = 0;
// Called by the compositor when page scale animation completed.
virtual void DidCompletePageScaleAnimation() = 0;
// Notifies that the compositor has posted a swapbuffers operation to the GPU
// process.
virtual void DidCompleteSwapBuffers() = 0;
// TODO(simonhong, fsamuel): Remove this once crbug.com/471411 is resolved.
// Indicates whether this RenderWidgetCompositor is for an out-of-process
// iframe or not.
virtual bool ForOOPIF() const = 0;
// Called by the compositor to forward a proto that represents serialized
// compositor state.
virtual void ForwardCompositorProto(const std::vector<uint8_t>& proto) = 0;
// Called by the compositor in single-threaded mode when a swap is aborted.
virtual void OnSwapBuffersAborted() = 0;
// Called by the compositor in single-threaded mode when a swap completes.
virtual void OnSwapBuffersComplete() = 0;
// Called by the compositor in single-threaded mode when a swap is posted.
virtual void OnSwapBuffersPosted() = 0;
// Called by the compositor to request the delegate to record frame timing.
virtual void RecordFrameTimingEvents(
scoped_ptr<cc::FrameTimingTracker::CompositeTimingSet> composite_events,
scoped_ptr<cc::FrameTimingTracker::MainFrameTimingSet>
main_frame_events) = 0;
// Requests that the client schedule a composite now, and calculate
// appropriate delay for potential future frame.
virtual void ScheduleAnimation() = 0;
// Requests a visual frame-based update to the state of the delegate if there
// an update available.
virtual void UpdateVisualState() = 0;
// Indicates that the compositor is about to begin a frame. This is primarily
// to signal to flow control mechanisms that a frame is beginning, not to
// perform actual painting work.
virtual void WillBeginCompositorFrame() = 0;
protected:
virtual ~RenderWidgetCompositorDelegate() {}
};
} // namespace content
#endif // CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_DELEGATE_H_
...@@ -62,9 +62,10 @@ class RenderWidgetCompositorTest : public testing::Test { ...@@ -62,9 +62,10 @@ class RenderWidgetCompositorTest : public testing::Test {
RenderWidgetCompositorTest() RenderWidgetCompositorTest()
: compositor_deps_(new FakeCompositorDependencies), : compositor_deps_(new FakeCompositorDependencies),
render_widget_(new TestRenderWidget(compositor_deps_.get())), render_widget_(new TestRenderWidget(compositor_deps_.get())),
render_widget_compositor_( render_widget_compositor_(RenderWidgetCompositor::Create(
RenderWidgetCompositor::Create(render_widget_.get(), render_widget_.get(),
compositor_deps_.get())) {} 1.f /* initial_device_scale_factor */,
compositor_deps_.get())) {}
~RenderWidgetCompositorTest() override {} ~RenderWidgetCompositorTest() override {}
protected: protected:
...@@ -243,7 +244,8 @@ class RenderWidgetCompositorOutputSurfaceTest : public testing::Test { ...@@ -243,7 +244,8 @@ class RenderWidgetCompositorOutputSurfaceTest : public testing::Test {
render_widget_(new RenderWidgetOutputSurface(compositor_deps_.get())) { render_widget_(new RenderWidgetOutputSurface(compositor_deps_.get())) {
render_widget_compositor_.reset(new RenderWidgetCompositorOutputSurface( render_widget_compositor_.reset(new RenderWidgetCompositorOutputSurface(
render_widget_.get(), compositor_deps_.get())); render_widget_.get(), compositor_deps_.get()));
render_widget_compositor_->Initialize(); render_widget_compositor_->Initialize(
1.f /* initial_device_scale_factor */);
render_widget_->SetCompositor(render_widget_compositor_.get()); render_widget_->SetCompositor(render_widget_compositor_.get());
} }
......
This diff is collapsed.
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "content/common/cursors/webcursor.h" #include "content/common/cursors/webcursor.h"
#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
#include "content/common/input/synthetic_gesture_params.h" #include "content/common/input/synthetic_gesture_params.h"
#include "content/renderer/gpu/render_widget_compositor_delegate.h"
#include "content/renderer/input/render_widget_input_handler.h" #include "content/renderer/input/render_widget_input_handler.h"
#include "content/renderer/input/render_widget_input_handler_delegate.h" #include "content/renderer/input/render_widget_input_handler_delegate.h"
#include "content/renderer/message_delivery_policy.h" #include "content/renderer/message_delivery_policy.h"
...@@ -103,6 +104,7 @@ class CONTENT_EXPORT RenderWidget ...@@ -103,6 +104,7 @@ class CONTENT_EXPORT RenderWidget
: public IPC::Listener, : public IPC::Listener,
public IPC::Sender, public IPC::Sender,
NON_EXPORTED_BASE(virtual public blink::WebWidgetClient), NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
public RenderWidgetCompositorDelegate,
public RenderWidgetInputHandlerDelegate, public RenderWidgetInputHandlerDelegate,
public base::RefCounted<RenderWidget> { public base::RefCounted<RenderWidget> {
public: public:
...@@ -137,7 +139,6 @@ class CONTENT_EXPORT RenderWidget ...@@ -137,7 +139,6 @@ class CONTENT_EXPORT RenderWidget
// Temporary for debugging purposes... // Temporary for debugging purposes...
bool closing() const { return closing_; } bool closing() const { return closing_; }
bool is_swapped_out() { return is_swapped_out_; } bool is_swapped_out() { return is_swapped_out_; }
bool for_oopif() { return for_oopif_; }
bool has_host_context_menu_location() { bool has_host_context_menu_location() {
return has_host_context_menu_location_; return has_host_context_menu_location_;
} }
...@@ -168,6 +169,32 @@ class CONTENT_EXPORT RenderWidget ...@@ -168,6 +169,32 @@ class CONTENT_EXPORT RenderWidget
// IPC::Sender // IPC::Sender
bool Send(IPC::Message* msg) override; bool Send(IPC::Message* msg) override;
// RenderWidgetCompositorDelegate
void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
const gfx::Vector2dF& outer_delta,
const gfx::Vector2dF& elastic_overscroll_delta,
float page_scale,
float top_controls_delta) override;
void BeginMainFrame(double frame_time_sec) override;
scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) override;
scoped_ptr<cc::BeginFrameSource> CreateExternalBeginFrameSource() override;
void DidCommitAndDrawCompositorFrame() override;
void DidCommitCompositorFrame() override;
void DidCompletePageScaleAnimation() override;
void DidCompleteSwapBuffers() override;
bool ForOOPIF() const override;
void ForwardCompositorProto(const std::vector<uint8_t>& proto) override;
void OnSwapBuffersAborted() override;
void OnSwapBuffersComplete() override;
void OnSwapBuffersPosted() override;
void RecordFrameTimingEvents(
scoped_ptr<cc::FrameTimingTracker::CompositeTimingSet> composite_events,
scoped_ptr<cc::FrameTimingTracker::MainFrameTimingSet> main_frame_events)
override;
void ScheduleAnimation() override;
void UpdateVisualState() override;
void WillBeginCompositorFrame() override;
// RenderWidgetInputHandlerDelegate // RenderWidgetInputHandlerDelegate
void FocusChangeComplete() override; void FocusChangeComplete() override;
bool HasTouchEventHandlersAt(const gfx::Point& point) const override; bool HasTouchEventHandlersAt(const gfx::Point& point) const override;
...@@ -256,8 +283,6 @@ class CONTENT_EXPORT RenderWidget ...@@ -256,8 +283,6 @@ class CONTENT_EXPORT RenderWidget
// we should not send an extra ack (see SendAckForMouseMoveFromDebugger). // we should not send an extra ack (see SendAckForMouseMoveFromDebugger).
void IgnoreAckForMouseMoveFromDebugger(); void IgnoreAckForMouseMoveFromDebugger();
virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback);
// Callback for use with synthetic gestures (e.g. BeginSmoothScroll). // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
typedef base::Callback<void()> SyntheticGestureCompletionCallback; typedef base::Callback<void()> SyntheticGestureCompletionCallback;
...@@ -286,9 +311,6 @@ class CONTENT_EXPORT RenderWidget ...@@ -286,9 +311,6 @@ class CONTENT_EXPORT RenderWidget
// Returns whether we currently should handle an IME event. // Returns whether we currently should handle an IME event.
bool ShouldHandleImeEvent(); bool ShouldHandleImeEvent();
// Called by the compositor when page scale animation completed.
virtual void DidCompletePageScaleAnimation() {}
// ScreenMetricsEmulator class manages screen emulation inside a render // ScreenMetricsEmulator class manages screen emulation inside a render
// widget. This includes resizing, placing view on the screen at desired // widget. This includes resizing, placing view on the screen at desired
// position, changing device scale factor, and scaling down the whole // position, changing device scale factor, and scaling down the whole
...@@ -298,37 +320,16 @@ class CONTENT_EXPORT RenderWidget ...@@ -298,37 +320,16 @@ class CONTENT_EXPORT RenderWidget
void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator); void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator);
gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor); gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
// Indicates that the compositor is about to begin a frame. This is primarily
// to signal to flow control mechanisms that a frame is beginning, not to
// perform actual painting work.
void WillBeginCompositorFrame();
// Notifies about a compositor frame commit operation having finished.
virtual void DidCommitCompositorFrame();
// Notifies that the draw commands for a committed frame have been issued.
void DidCommitAndDrawCompositorFrame();
// Notifies that the compositor has posted a swapbuffers operation to the GPU
// process.
void DidCompleteSwapBuffers();
void ScheduleComposite(); void ScheduleComposite();
void ScheduleCompositeWithForcedRedraw(); void ScheduleCompositeWithForcedRedraw();
// Called by the compositor in single-threaded mode when a swap is posted,
// completes or is aborted.
void OnSwapBuffersPosted();
void OnSwapBuffersComplete();
void OnSwapBuffersAborted();
// Checks if the selection bounds have been changed. If they are changed, // Checks if the selection bounds have been changed. If they are changed,
// the new value will be sent to the browser process. // the new value will be sent to the browser process.
void UpdateSelectionBounds(); void UpdateSelectionBounds();
// Called by the compositor to forward a proto that represents serialized // Called by the compositor to forward a proto that represents serialized
// compositor state. // compositor state.
void ForwardCompositorProto(const std::vector<uint8_t>& proto);
virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end); virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
...@@ -340,8 +341,6 @@ class CONTENT_EXPORT RenderWidget ...@@ -340,8 +341,6 @@ class CONTENT_EXPORT RenderWidget
// handle composition range and composition character bounds. // handle composition range and composition character bounds.
void UpdateCompositionInfo(bool should_update_range); void UpdateCompositionInfo(bool should_update_range);
bool host_closing() const { return host_closing_; }
protected: protected:
// Friend RefCounted so that the dtor can be non-public. Using this class // Friend RefCounted so that the dtor can be non-public. Using this class
// without ref-counting is an error. // without ref-counting is an error.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment