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

Unified Diff: chrome/renderer/chrome_render_view_observer.cc

Issue 11138024: Simplify platform_canvas.h by recognizing that PlatformCanvas does not actually extend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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: chrome/renderer/chrome_render_view_observer.cc
===================================================================
--- chrome/renderer/chrome_render_view_observer.cc (revision 167659)
+++ chrome/renderer/chrome_render_view_observer.cc (working copy)
@@ -150,22 +150,6 @@
// Constants for mixed-content blocking.
static const char kGoogleDotCom[] = "google.com";
-static bool PaintViewIntoCanvas(WebView* view,
- skia::PlatformCanvas& canvas) {
- view->layout();
- const WebSize& size = view->size();
-
- if (!canvas.initialize(size.width, size.height, true))
- return false;
-
- view->paint(webkit_glue::ToWebCanvas(&canvas),
- WebRect(0, 0, size.width, size.height));
- // TODO: Add a way to snapshot the whole page, not just the currently
- // visible part.
-
- return true;
-}
-
static FaviconURL::IconType ToFaviconType(WebIconURL::Type type) {
switch (type) {
case WebIconURL::TypeFavicon:
@@ -904,12 +888,22 @@
SkBitmap* snapshot) {
base::TimeTicks beginning_time = base::TimeTicks::Now();
- skia::PlatformCanvas canvas;
- if (!PaintViewIntoCanvas(view, canvas))
+ view->layout();
+ const WebSize& size = view->size();
+
+ SkCanvas* canvas = skia::CreatePlatformCanvas(size.width, size.height, true,
+ NULL, skia::RETURN_NULL_ON_FAILURE);
+ if (!canvas)
return false;
- SkDevice* device = skia::GetTopDevice(canvas);
+ SkAutoUnref au(canvas);
+ view->paint(webkit_glue::ToWebCanvas(canvas),
+ WebRect(0, 0, size.width, size.height));
+ // TODO: Add a way to snapshot the whole page, not just the currently
+ // visible part.
+ SkDevice* device = skia::GetTopDevice(*canvas);
+
const SkBitmap& bitmap = device->accessBitmap(false);
if (!bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config))
return false;
« no previous file with comments | « chrome/renderer/automation/automation_renderer_helper.cc ('k') | chrome/renderer/safe_browsing/phishing_thumbnailer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698