summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-14 22:53:09 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-14 22:53:09 +0000
commitc82e56ca13fefb0a50662ef1cee872c06cd2b5e3 (patch)
tree262e4b27fc00f4a45aaa65f4ca88a0311a28cd8f
parent24729272479b4f42bb137d8e3e50c445cd72e30e (diff)
downloadchromium_src-c82e56ca13fefb0a50662ef1cee872c06cd2b5e3.zip
chromium_src-c82e56ca13fefb0a50662ef1cee872c06cd2b5e3.tar.gz
chromium_src-c82e56ca13fefb0a50662ef1cee872c06cd2b5e3.tar.bz2
Convert CaptureImage to a single method with lots of ifdefs.
Original patch from icefox (Torchmobile) in http://codereview.chromium.org/7244 . Review URL: http://codereview.chromium.org/7150 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3376 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/glue/webframe_impl.cc45
1 files changed, 9 insertions, 36 deletions
diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc
index accc174..316be1b 100644
--- a/webkit/glue/webframe_impl.cc
+++ b/webkit/glue/webframe_impl.cc
@@ -1494,59 +1494,32 @@ void WebFrameImpl::Paint(gfx::PlatformCanvas* canvas, const gfx::Rect& rect) {
}
}
-// TODO(tc): Merge these as they are almost identical across platforms.
-#if defined(OS_WIN)
gfx::BitmapPlatformDevice WebFrameImpl::CaptureImage(bool scroll_to_zero) {
// Must layout before painting.
Layout();
- gfx::PlatformCanvasWin canvas(frameview()->width(), frameview()->height(), true);
+ gfx::PlatformCanvas canvas(frameview()->width(), frameview()->height(), true);
+#if defined(OS_WIN) || defined(OS_LINUX)
PlatformContextSkia context(&canvas);
-
GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context));
- frameview()->paint(&gc, IntRect(0, 0, frameview()->width(),
- frameview()->height()));
-
- gfx::BitmapPlatformDeviceWin& device =
- static_cast<gfx::BitmapPlatformDeviceWin&>(canvas.getTopPlatformDevice());
- device.fixupAlphaBeforeCompositing();
- return device;
-}
#elif defined(OS_MACOSX)
-gfx::BitmapPlatformDevice WebFrameImpl::CaptureImage(bool scroll_to_zero) {
- // Must layout before painting.
- Layout();
-
- gfx::PlatformCanvasMac canvas(frameview()->width(),
- frameview()->height(), true);
CGContextRef context = canvas.beginPlatformPaint();
GraphicsContext gc(context);
+#endif
frameview()->paint(&gc, IntRect(0, 0, frameview()->width(),
- frameview()->height()));
+ frameview()->height()));
+#if defined(OS_MACOSX)
canvas.endPlatformPaint();
+#endif
gfx::BitmapPlatformDevice& device =
static_cast<gfx::BitmapPlatformDevice&>(canvas.getTopPlatformDevice());
- return device;
-}
-#else
-gfx::BitmapPlatformDevice WebFrameImpl::CaptureImage(bool scroll_to_zero) {
- // Must layout before painting.
- Layout();
- gfx::PlatformCanvasLinux canvas(frameview()->width(), frameview()->height(),
- true);
- PlatformContextSkia context(&canvas);
-
- GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context));
- frameview()->paint(&gc, IntRect(0, 0, frameview()->width(),
- frameview()->height()));
-
- gfx::BitmapPlatformDevice& device =
- static_cast<gfx::BitmapPlatformDevice&>(canvas.getTopPlatformDevice());
+#if defined(OS_WIN)
+ device.fixupAlphaBeforeCompositing();
+#endif
return device;
}
-#endif
bool WebFrameImpl::IsLoading() {
// I'm assuming this does what we want.