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

Unified Diff: content/renderer/render_view_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: Change public interface instead 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
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 6578cd88cc32fd13c51f6a9b28eb23dc2ec6a2cd..7bdf278df97fc50af28fc2877cb3b22982d8e7cd 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -1116,6 +1116,7 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
OnReleaseDisambiguationPopupDIB)
IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted,
OnWindowSnapshotCompleted)
+ IPC_MESSAGE_HANDLER(ViewMsg_Snapshot, OnSnapshot)
// Have the super handle all other messages.
IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message))
@@ -1899,6 +1900,55 @@ void RenderViewImpl::OnWindowSnapshotCompleted(const int snapshot_id,
pending_snapshots_.erase(it);
}
+namespace {
+
+bool CaptureSnapshot(WebView* view,
+ const gfx::Rect& src_subrect,
+ SkBitmap* snapshot) {
+ base::TimeTicks beginning_time = base::TimeTicks::Now();
+
+ view->layout();
+ const WebSize& size = view->size();
jamesr 2013/03/18 22:41:18 I'm not sure about this - the size of a WebWidget
justinlin 2013/03/18 23:27:51 Done. Yea, this old stuff didn't really work with
+ gfx::Rect viewport_size = gfx::IntersectRects(
+ src_subrect, gfx::Rect(size.width, size.height));
+
+ skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(
+ skia::CreatePlatformCanvas(viewport_size.width(),
+ viewport_size.height(),
+ true,
+ NULL,
+ skia::RETURN_NULL_ON_FAILURE));
+ if (!canvas)
+ return false;
+
+ view->paint(webkit_glue::ToWebCanvas(canvas.get()), viewport_size);
+
+ const SkBitmap& bitmap = skia::GetTopDevice(*canvas)->accessBitmap(false);
+ if (!bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config))
+ return false;
+
+ UMA_HISTOGRAM_TIMES("Renderer4.Snapshot",
+ base::TimeTicks::Now() - beginning_time);
+ return true;
+}
+
+} // namespace
+
+void RenderViewImpl::OnSnapshot(const gfx::Rect& src_subrect) {
+ SkBitmap snapshot;
+ bool error = false;
+
+ if (!webview()->mainFrame() || !CaptureSnapshot(webview(),
+ src_subrect,
+ &snapshot))
+ error = true;
+
+ DCHECK(error == snapshot.empty()) <<
+ "Snapshot should be empty on error, non-empty otherwise.";
+
+ Send(new ViewHostMsg_Snapshot(routing_id_, !error, snapshot));
+}
+
// WebKit::WebViewClient ------------------------------------------------------
WebView* RenderViewImpl::createView(
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698