| 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 2c9d0d2cb200ad954da2e802efaa9533c3f01721..7dcf9e00800680dea2e8d6b997b71226c4f22626 100644
|
| --- a/content/browser/renderer_host/render_widget_host_impl.cc
|
| +++ b/content/browser/renderer_host/render_widget_host_impl.cc
|
| @@ -391,6 +391,7 @@ bool RenderWidgetHostImpl::OnMessageReceived(const IPC::Message &msg) {
|
| IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowDestroyed,
|
| OnWindowlessPluginDummyWindowDestroyed)
|
| #endif
|
| + IPC_MESSAGE_HANDLER(ViewHostMsg_Snapshot, OnSnapshot)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| IPC_END_MESSAGE_MAP_EX()
|
|
|
| @@ -570,12 +571,13 @@ void RenderWidgetHostImpl::CopyFromBackingStore(
|
| const gfx::Rect& src_subrect,
|
| const gfx::Size& accelerated_dst_size,
|
| const base::Callback<void(bool, const SkBitmap&)>& callback) {
|
| +
|
| if (view_ && is_accelerated_compositing_active_) {
|
| TRACE_EVENT0("browser",
|
| "RenderWidgetHostImpl::CopyFromBackingStore::FromCompositingSurface");
|
| - gfx::Rect copy_rect = src_subrect.IsEmpty() ?
|
| + gfx::Rect accelerated_copy_rect = src_subrect.IsEmpty() ?
|
| gfx::Rect(view_->GetViewBounds().size()) : src_subrect;
|
| - view_->CopyFromCompositingSurface(copy_rect,
|
| + view_->CopyFromCompositingSurface(accelerated_copy_rect,
|
| accelerated_dst_size,
|
| callback);
|
| return;
|
| @@ -598,6 +600,45 @@ void RenderWidgetHostImpl::CopyFromBackingStore(
|
| callback.Run(result, output.GetBitmap());
|
| }
|
|
|
| +void RenderWidgetHostImpl::GetSnapshotFromRenderer(
|
| + const gfx::Rect& src_subrect,
|
| + const gfx::Size& dst_size,
|
| + const base::Callback<void(bool, const SkBitmap&)>& callback) {
|
| + TRACE_EVENT0("browser", "RenderWidgetHostImpl::GetSnapshotFromRenderer");
|
| + pending_snapshots_.push(std::make_pair(dst_size, callback));
|
| +
|
| + gfx::Rect copy_rect = src_subrect.IsEmpty() ?
|
| + gfx::Rect(view_->GetViewBounds().size()) : src_subrect;
|
| + Send(new ViewMsg_Snapshot(routing_id_, copy_rect));
|
| +}
|
| +
|
| +void RenderWidgetHostImpl::OnSnapshot(bool success,
|
| + const SkBitmap& bitmap) {
|
| + if (pending_snapshots_.size() == 0) {
|
| + LOG(ERROR) << "RenderWidgetHostImpl::OnSnapshot: "
|
| + "Received a snapshot that was not requested.";
|
| + return;
|
| + }
|
| +
|
| + PendingSnapshotInfo snapshot_info = pending_snapshots_.front();
|
| + pending_snapshots_.pop();
|
| +
|
| + const gfx::Size& dst_size = snapshot_info.first;
|
| + const base::Callback<void(bool, const SkBitmap&)>& callback =
|
| + snapshot_info.second;
|
| +
|
| + if (!success) {
|
| + callback.Run(success, SkBitmap());
|
| + return;
|
| + }
|
| +
|
| + SkBitmap resized = skia::ImageOperations::Resize(
|
| + bitmap, skia::ImageOperations::RESIZE_GOOD, dst_size.width(),
|
| + dst_size.height());
|
| +
|
| + callback.Run(success, resized);
|
| +}
|
| +
|
| #if defined(TOOLKIT_GTK)
|
| bool RenderWidgetHostImpl::CopyFromBackingStoreToGtkWindow(
|
| const gfx::Rect& dest_rect, GdkWindow* target) {
|
|
|