From c82e56ca13fefb0a50662ef1cee872c06cd2b5e3 Mon Sep 17 00:00:00 2001 From: "tc@google.com" Date: Tue, 14 Oct 2008 22:53:09 +0000 Subject: 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 --- webkit/glue/webframe_impl.cc | 45 +++++++++----------------------------------- 1 file 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(&context)); - frameview()->paint(&gc, IntRect(0, 0, frameview()->width(), - frameview()->height())); - - gfx::BitmapPlatformDeviceWin& device = - static_cast(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(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(&context)); - frameview()->paint(&gc, IntRect(0, 0, frameview()->width(), - frameview()->height())); - - gfx::BitmapPlatformDevice& device = - static_cast(canvas.getTopPlatformDevice()); +#if defined(OS_WIN) + device.fixupAlphaBeforeCompositing(); +#endif return device; } -#endif bool WebFrameImpl::IsLoading() { // I'm assuming this does what we want. -- cgit v1.1