summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 17:51:02 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 17:51:02 +0000
commit8649fb3771f7d6227e5fea231050c7da63fb0e08 (patch)
tree740947d3576a2227c4420d313435dbd5c1e40a51 /chrome
parentc3546c5dd8cfba47dac4026e024d59ed9bbcdd0c (diff)
downloadchromium_src-8649fb3771f7d6227e5fea231050c7da63fb0e08.zip
chromium_src-8649fb3771f7d6227e5fea231050c7da63fb0e08.tar.gz
chromium_src-8649fb3771f7d6227e5fea231050c7da63fb0e08.tar.bz2
Remove WebFrame::CaptureImage in favor of having consumers call Layout
and Paint manually on the WebView. BUG=10034 TEST=none R=brettw Review URL: http://codereview.chromium.org/147212 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19379 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/renderer/render_view.cc22
-rw-r--r--chrome/renderer/render_view.h2
2 files changed, 16 insertions, 8 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index a164d10..051b8d6 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -107,6 +107,7 @@ using WebKit::WebHistoryItem;
using WebKit::WebNavigationType;
using WebKit::WebRect;
using WebKit::WebScriptSource;
+using WebKit::WebSize;
using WebKit::WebString;
using WebKit::WebURL;
using WebKit::WebURLError;
@@ -432,7 +433,7 @@ void RenderView::SendThumbnail() {
ThumbnailScore score;
SkBitmap thumbnail;
- if (!CaptureThumbnail(main_frame, kThumbnailWidth, kThumbnailHeight,
+ if (!CaptureThumbnail(webview(), kThumbnailWidth, kThumbnailHeight,
&thumbnail, &score))
return;
@@ -538,7 +539,7 @@ void RenderView::CaptureText(WebFrame* frame, std::wstring* contents) {
}
}
-bool RenderView::CaptureThumbnail(WebFrame* frame,
+bool RenderView::CaptureThumbnail(WebView* view,
int w,
int h,
SkBitmap* thumbnail,
@@ -547,11 +548,18 @@ bool RenderView::CaptureThumbnail(WebFrame* frame,
double begin = time_util::GetHighResolutionTimeNow();
#endif
- scoped_ptr<skia::BitmapPlatformDevice> device;
- if (!frame->CaptureImage(&device, true))
+ view->Layout();
+ const WebSize& size = view->GetSize();
+
+ skia::PlatformCanvas canvas;
+ if (!canvas.initialize(size.width, size.height, true))
return false;
+ view->Paint(&canvas, WebRect(0, 0, size.width, size.height));
+
+ skia::BitmapPlatformDevice& device =
+ static_cast<skia::BitmapPlatformDevice&>(canvas.getTopPlatformDevice());
- const SkBitmap& src_bmp = device->accessBitmap(false);
+ const SkBitmap& src_bmp = device.accessBitmap(false);
SkRect dest_rect;
dest_rect.set(0, 0, SkIntToScalar(w), SkIntToScalar(h));
@@ -584,10 +592,10 @@ bool RenderView::CaptureThumbnail(WebFrame* frame,
}
}
- score->at_top = (frame->ScrollOffset().height == 0);
+ score->at_top = (view->GetMainFrame()->ScrollOffset().height == 0);
SkBitmap subset;
- device->accessBitmap(false).extractSubset(&subset, src_rect);
+ device.accessBitmap(false).extractSubset(&subset, src_rect);
// Resample the subset that we want to get it the right size.
*thumbnail = skia::ImageOperations::Resize(
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 8a65ebb..07cbc02 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -430,7 +430,7 @@ class RenderView : public RenderWidget,
// Creates a thumbnail of |frame|'s contents resized to (|w|, |h|)
// and puts that in |thumbnail|. Thumbnail metadata goes in |score|.
- bool CaptureThumbnail(WebFrame* frame, int w, int h,
+ bool CaptureThumbnail(WebView* view, int w, int h,
SkBitmap* thumbnail,
ThumbnailScore* score);