Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1837)

Unified Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 12881005: Allow CopyFromBackingStore to fallback to copying from the renderer side if the accelerated surface… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fallback to renderer side copy when backing store is not avilable too Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..1fb7dedf61df56c7e733da9f2b4449ed94d8562d 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,14 @@ void RenderWidgetHostImpl::CopyFromBackingStore(
const gfx::Rect& src_subrect,
const gfx::Size& accelerated_dst_size,
const base::Callback<void(bool, const SkBitmap&)>& callback) {
+ gfx::Rect accelerated_copy_rect = src_subrect.IsEmpty() ?
+ gfx::Rect(view_->GetViewBounds().size()) : src_subrect;
+
if (view_ && is_accelerated_compositing_active_) {
TRACE_EVENT0("browser",
"RenderWidgetHostImpl::CopyFromBackingStore::FromCompositingSurface");
- gfx::Rect 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;
@@ -583,7 +586,9 @@ void RenderWidgetHostImpl::CopyFromBackingStore(
BackingStore* backing_store = GetBackingStore(false);
if (!backing_store) {
- callback.Run(false, SkBitmap());
+ GetSnapshotFromRenderer(accelerated_copy_rect,
Sam Kerner (Chrome) 2013/03/18 19:30:52 You are changing the semantics of this method from
+ accelerated_dst_size,
+ callback);
return;
}
@@ -598,6 +603,42 @@ 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));
+ Send(new ViewMsg_Snapshot(routing_id_, src_subrect));
+}
+
+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) {
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/browser/renderer_host/render_widget_host_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698