Chromium Code Reviews| 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..ca5109618e13bf96c0c97e6c6f8a4283bc3f211e 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() |
| @@ -573,9 +574,9 @@ void RenderWidgetHostImpl::CopyFromBackingStore( |
| 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 +599,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(), |
|
jamesr
2013/03/18 22:41:18
why RESIZE_GOOD? what did the old code use?
justinlin
2013/03/18 23:27:52
The old code didn't really do the resize (CopyFrom
|
| + dst_size.height()); |
| + |
| + callback.Run(success, resized); |
| +} |
| + |
| #if defined(TOOLKIT_GTK) |
| bool RenderWidgetHostImpl::CopyFromBackingStoreToGtkWindow( |
| const gfx::Rect& dest_rect, GdkWindow* target) { |