Index: content/browser/renderer_host/render_widget_host_impl.cc |
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc |
index 1cf7f5d6cfe033a8ee3ea7de8fe78542b6b3d172..5e17d2bbfbadf5192c72d6f374065ba8e92fd40b 100644 |
--- a/content/browser/renderer_host/render_widget_host_impl.cc |
+++ b/content/browser/renderer_host/render_widget_host_impl.cc |
@@ -14,6 +14,7 @@ |
#include "base/debug/trace_event.h" |
#include "base/i18n/rtl.h" |
#include "base/lazy_instance.h" |
+#include "base/logging.h" |
#include "base/message_loop/message_loop.h" |
#include "base/metrics/field_trial.h" |
#include "base/metrics/histogram.h" |
@@ -56,6 +57,7 @@ |
#include "ui/gfx/size_conversions.h" |
#include "ui/gfx/skbitmap_operations.h" |
#include "ui/gfx/vector2d_conversions.h" |
+#include "ui/snapshot/snapshot.h" |
#include "webkit/common/cursors/webcursor.h" |
#include "webkit/common/webpreferences.h" |
@@ -174,6 +176,8 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, |
is_threaded_compositing_enabled_ = IsThreadedCompositingEnabled(); |
+ LOG(INFO) << "RenderWidgetHostImpl: created for process id = " << process->GetID() << " routing id = " << routing_id_; |
+ |
g_routing_id_widget_map.Get().insert(std::make_pair( |
RenderWidgetHostID(process->GetID(), routing_id_), this)); |
process_->AddRoute(routing_id_, this); |
@@ -2452,6 +2456,15 @@ void RenderWidgetHostImpl::ComputeTouchLatency( |
} |
void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { |
+ LOG(INFO) << "RenderWidgetHostImpl::FrameSwapped"; |
+ ui::LatencyInfo::LatencyComponent window_snapshot_component; |
+ if (latency_info.FindLatency(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, |
+ GetLatencyComponentId(), |
+ &window_snapshot_component)) { |
+ WindowSnapshotReachedScreen( |
+ static_cast<int>(window_snapshot_component.sequence_number)); |
+ } |
+ |
ui::LatencyInfo::LatencyComponent rwh_component; |
if (!latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, |
GetLatencyComponentId(), |
@@ -2496,23 +2509,56 @@ void RenderWidgetHostImpl::DidReceiveRendererFrame() { |
view_->DidReceiveRendererFrame(); |
} |
+void RenderWidgetHostImpl::WindowSnapshotReachedScreen(int snapshot_id) { |
+ LOG(INFO) << "RenderWidgetHostImpl::WindowSnapshotReachedScreen: " << snapshot_id; |
+ |
+ DCHECK(base::MessageLoop::current()->IsType(base::MessageLoop::TYPE_UI)); |
+ |
+ std::vector<unsigned char> png; |
+ |
+ // This feature is behind the kEnableGpuBenchmarking command line switch |
+ // because it poses security concerns and should only be used for testing. |
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
jbauman
2013/09/13 22:33:24
Can multiple snapshots be outstanding at once? If
|
+ if (command_line.HasSwitch(switches::kEnableGpuBenchmarking)) { |
+ gfx::Rect view_bounds = GetView()->GetViewBounds(); |
+ gfx::Rect snapshot_bounds(view_bounds.size()); |
+ gfx::Size snapshot_size = snapshot_bounds.size(); |
+ |
+ if (ui::GrabViewSnapshot(GetView()->GetNativeView(), |
+ &png, snapshot_bounds)) { |
+ Send(new ViewMsg_WindowSnapshotCompleted( |
+ GetRoutingID(), snapshot_id, snapshot_size, png)); |
+ return; |
+ } |
+ } |
+ |
+ Send(new ViewMsg_WindowSnapshotCompleted( |
+ GetRoutingID(), snapshot_id, gfx::Size(), png)); |
+} |
+ |
// static |
void RenderWidgetHostImpl::CompositorFrameDrawn( |
const ui::LatencyInfo& latency_info) { |
+ LOG(INFO) << "RenderWidgetHostImpl::CompositorFrameDrawn top level"; |
for (ui::LatencyInfo::LatencyMap::const_iterator b = |
latency_info.latency_components.begin(); |
b != latency_info.latency_components.end(); |
++b) { |
- if (b->first.first != ui::INPUT_EVENT_LATENCY_RWH_COMPONENT) |
- continue; |
- // Matches with GetLatencyComponentId |
- int routing_id = b->first.second & 0xffffffff; |
- int process_id = (b->first.second >> 32) & 0xffffffff; |
- RenderWidgetHost* rwh = |
- RenderWidgetHost::FromID(process_id, routing_id); |
- if (!rwh) |
+ if (b->first.first == ui::INPUT_EVENT_LATENCY_RWH_COMPONENT || |
+ b->first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT) { |
+ // Matches with GetLatencyComponentId |
+ int routing_id = b->first.second & 0xffffffff; |
+ int process_id = (b->first.second >> 32) & 0xffffffff; |
+ LOG(INFO) << "RenderWidgetHostImpl::CompositorFrameDrawn: type = " << (int) b->first.first << " process id = " << process_id << " routing_id = " << routing_id; |
+ RenderWidgetHost* rwh = |
+ RenderWidgetHost::FromID(process_id, routing_id); |
+ if (!rwh) { |
+ LOG(INFO) << " (no such RenderWidgetHost)"; |
+ continue; |
+ } |
+ RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); |
jbauman
2013/09/13 22:33:24
You should probably make a set of RWHI to send the
|
continue; |
- RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); |
+ } |
} |
} |