Commit f9f3fac9 authored by dgozman@chromium.org's avatar dgozman@chromium.org

[DevTools] Force page redraw when enabling screencast.

When attaching to a static page, it may not produce new frames, thus
rendering screencast useless. Forcing a frame helps in this case.

BUG=none

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287421 0039d316-1c4b-4281-b951-d872f2087c98
parent 1f0bc15f
...@@ -90,6 +90,7 @@ void ParseGenericInputParams(base::DictionaryValue* params, ...@@ -90,6 +90,7 @@ void ParseGenericInputParams(base::DictionaryValue* params,
RendererOverridesHandler::RendererOverridesHandler(DevToolsAgentHost* agent) RendererOverridesHandler::RendererOverridesHandler(DevToolsAgentHost* agent)
: agent_(agent), : agent_(agent),
has_last_compositor_frame_metadata_(false),
capture_retry_count_(0), capture_retry_count_(0),
weak_factory_(this) { weak_factory_(this) {
RegisterCommandHandler( RegisterCommandHandler(
...@@ -191,6 +192,7 @@ void RendererOverridesHandler::OnClientDetached() { ...@@ -191,6 +192,7 @@ void RendererOverridesHandler::OnClientDetached() {
void RendererOverridesHandler::OnSwapCompositorFrame( void RendererOverridesHandler::OnSwapCompositorFrame(
const cc::CompositorFrameMetadata& frame_metadata) { const cc::CompositorFrameMetadata& frame_metadata) {
last_compositor_frame_metadata_ = frame_metadata; last_compositor_frame_metadata_ = frame_metadata;
has_last_compositor_frame_metadata_ = true;
if (screencast_command_) if (screencast_command_)
InnerSwapCompositorFrame(); InnerSwapCompositorFrame();
...@@ -541,8 +543,12 @@ RendererOverridesHandler::PageStartScreencast( ...@@ -541,8 +543,12 @@ RendererOverridesHandler::PageStartScreencast(
host->SetTouchEventEmulationEnabled(true, true); host->SetTouchEventEmulationEnabled(true, true);
bool visible = !host->is_hidden(); bool visible = !host->is_hidden();
NotifyScreencastVisibility(visible); NotifyScreencastVisibility(visible);
if (visible) if (visible) {
InnerSwapCompositorFrame(); if (has_last_compositor_frame_metadata_)
InnerSwapCompositorFrame();
else
host->Send(new ViewMsg_ForceRedraw(host->GetRoutingID(), 0));
}
return command->SuccessResponse(NULL); return command->SuccessResponse(NULL);
} }
......
...@@ -109,6 +109,7 @@ class CONTENT_EXPORT RendererOverridesHandler ...@@ -109,6 +109,7 @@ class CONTENT_EXPORT RendererOverridesHandler
DevToolsAgentHost* agent_; DevToolsAgentHost* agent_;
scoped_refptr<DevToolsProtocol::Command> screencast_command_; scoped_refptr<DevToolsProtocol::Command> screencast_command_;
bool has_last_compositor_frame_metadata_;
cc::CompositorFrameMetadata last_compositor_frame_metadata_; cc::CompositorFrameMetadata last_compositor_frame_metadata_;
base::TimeTicks last_frame_time_; base::TimeTicks last_frame_time_;
int capture_retry_count_; int capture_retry_count_;
......
...@@ -186,7 +186,7 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, ...@@ -186,7 +186,7 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,
has_touch_handler_(false), has_touch_handler_(false),
weak_factory_(this), weak_factory_(this),
last_input_number_(static_cast<int64>(GetProcess()->GetID()) << 32), last_input_number_(static_cast<int64>(GetProcess()->GetID()) << 32),
next_browser_snapshot_id_(0) { next_browser_snapshot_id_(1) {
CHECK(delegate_); CHECK(delegate_);
if (routing_id_ == MSG_ROUTING_NONE) { if (routing_id_ == MSG_ROUTING_NONE) {
routing_id_ = process_->GetNextRoutingID(); routing_id_ = process_->GetNextRoutingID();
......
...@@ -977,6 +977,8 @@ IPC_MESSAGE_ROUTED2(ViewMsg_ReclaimCompositorResources, ...@@ -977,6 +977,8 @@ IPC_MESSAGE_ROUTED2(ViewMsg_ReclaimCompositorResources,
IPC_MESSAGE_ROUTED0(ViewMsg_SelectWordAroundCaret) IPC_MESSAGE_ROUTED0(ViewMsg_SelectWordAroundCaret)
// Sent by the browser to ask the renderer to redraw. // Sent by the browser to ask the renderer to redraw.
// If |request_id| is not zero, it is added to the forced frame's latency info
// as ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT.
IPC_MESSAGE_ROUTED1(ViewMsg_ForceRedraw, IPC_MESSAGE_ROUTED1(ViewMsg_ForceRedraw,
int /* request_id */) int /* request_id */)
......
...@@ -1633,9 +1633,11 @@ void RenderViewImpl::GetWindowSnapshot(const WindowSnapshotCallback& callback) { ...@@ -1633,9 +1633,11 @@ void RenderViewImpl::GetWindowSnapshot(const WindowSnapshotCallback& callback) {
void RenderViewImpl::OnForceRedraw(int id) { void RenderViewImpl::OnForceRedraw(int id) {
ui::LatencyInfo latency_info; ui::LatencyInfo latency_info;
latency_info.AddLatencyNumber(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, if (id) {
0, latency_info.AddLatencyNumber(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT,
id); 0,
id);
}
scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor; scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor;
if (RenderWidgetCompositor* rwc = compositor()) { if (RenderWidgetCompositor* rwc = compositor()) {
latency_info_swap_promise_monitor = latency_info_swap_promise_monitor =
......
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