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,
RendererOverridesHandler::RendererOverridesHandler(DevToolsAgentHost* agent)
: agent_(agent),
has_last_compositor_frame_metadata_(false),
capture_retry_count_(0),
weak_factory_(this) {
RegisterCommandHandler(
......@@ -191,6 +192,7 @@ void RendererOverridesHandler::OnClientDetached() {
void RendererOverridesHandler::OnSwapCompositorFrame(
const cc::CompositorFrameMetadata& frame_metadata) {
last_compositor_frame_metadata_ = frame_metadata;
has_last_compositor_frame_metadata_ = true;
if (screencast_command_)
InnerSwapCompositorFrame();
......@@ -541,8 +543,12 @@ RendererOverridesHandler::PageStartScreencast(
host->SetTouchEventEmulationEnabled(true, true);
bool visible = !host->is_hidden();
NotifyScreencastVisibility(visible);
if (visible)
InnerSwapCompositorFrame();
if (visible) {
if (has_last_compositor_frame_metadata_)
InnerSwapCompositorFrame();
else
host->Send(new ViewMsg_ForceRedraw(host->GetRoutingID(), 0));
}
return command->SuccessResponse(NULL);
}
......
......@@ -109,6 +109,7 @@ class CONTENT_EXPORT RendererOverridesHandler
DevToolsAgentHost* agent_;
scoped_refptr<DevToolsProtocol::Command> screencast_command_;
bool has_last_compositor_frame_metadata_;
cc::CompositorFrameMetadata last_compositor_frame_metadata_;
base::TimeTicks last_frame_time_;
int capture_retry_count_;
......
......@@ -186,7 +186,7 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,
has_touch_handler_(false),
weak_factory_(this),
last_input_number_(static_cast<int64>(GetProcess()->GetID()) << 32),
next_browser_snapshot_id_(0) {
next_browser_snapshot_id_(1) {
CHECK(delegate_);
if (routing_id_ == MSG_ROUTING_NONE) {
routing_id_ = process_->GetNextRoutingID();
......
......@@ -977,6 +977,8 @@ IPC_MESSAGE_ROUTED2(ViewMsg_ReclaimCompositorResources,
IPC_MESSAGE_ROUTED0(ViewMsg_SelectWordAroundCaret)
// 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,
int /* request_id */)
......
......@@ -1633,9 +1633,11 @@ void RenderViewImpl::GetWindowSnapshot(const WindowSnapshotCallback& callback) {
void RenderViewImpl::OnForceRedraw(int id) {
ui::LatencyInfo latency_info;
latency_info.AddLatencyNumber(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT,
0,
id);
if (id) {
latency_info.AddLatencyNumber(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT,
0,
id);
}
scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor;
if (RenderWidgetCompositor* rwc = compositor()) {
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