summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorvandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-25 16:16:02 +0000
committervandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-25 16:16:02 +0000
commitf2d4c672b6d6b80e376cff979b1ec28864b73fb6 (patch)
tree679a4a8178438947f2775a6d1ba5540be99ce00c /chrome/renderer
parent49578ea329dae7f711ca1cde1ecade01e19a4f1b (diff)
downloadchromium_src-f2d4c672b6d6b80e376cff979b1ec28864b73fb6.zip
chromium_src-f2d4c672b6d6b80e376cff979b1ec28864b73fb6.tar.gz
chromium_src-f2d4c672b6d6b80e376cff979b1ec28864b73fb6.tar.bz2
Revert 86625 - This change implements a first pass in the effort to remove the dependency of PlatformDevice within Chrome. The Skia library now provides multiple back-ends for the SkDevice class, so PlatformDevice's inheritance of SkDevice, and the assumption of instances of PlatformDevice limits the use of these new back-ends.
A new set of helper functions is provided for the PlatformDevice entry points. Upon construction of a PlatformDevice, a pointer to the interface is cached in the parent SkDevice's SkMetaData. The new helper functions forward calls to the interface cached in the metadata. BUG=NONE TEST=NONE Review URL: http://codereview.chromium.org/7019013 TBR=twiz@chromium.org Review URL: http://codereview.chromium.org/6987019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86629 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/chrome_render_view_observer.cc13
-rw-r--r--chrome/renderer/print_web_view_helper_linux.cc2
-rw-r--r--chrome/renderer/print_web_view_helper_win.cc6
-rw-r--r--chrome/renderer/safe_browsing/phishing_thumbnailer.cc6
4 files changed, 16 insertions, 11 deletions
diff --git a/chrome/renderer/chrome_render_view_observer.cc b/chrome/renderer/chrome_render_view_observer.cc
index 9c19c19..113dc62 100644
--- a/chrome/renderer/chrome_render_view_observer.cc
+++ b/chrome/renderer/chrome_render_view_observer.cc
@@ -26,6 +26,7 @@
#include "content/renderer/content_renderer_client.h"
#include "googleurl/src/gurl.h"
#include "net/base/data_url.h"
+#include "skia/ext/bitmap_platform_device.h"
#include "skia/ext/image_operations.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h"
@@ -594,9 +595,10 @@ bool ChromeRenderViewObserver::CaptureFrameThumbnail(WebView* view,
if (!PaintViewIntoCanvas(view, canvas))
return false;
- SkDevice* device = skia::GetTopDevice(canvas);
+ 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 = { 0, 0, SkIntToScalar(w), SkIntToScalar(h) };
float dest_aspect = dest_rect.width() / dest_rect.height();
@@ -631,7 +633,7 @@ bool ChromeRenderViewObserver::CaptureFrameThumbnail(WebView* view,
score->at_top = (view->mainFrame()->scrollOffset().height == 0);
SkBitmap subset;
- device->accessBitmap(false).extractSubset(&subset, src_rect);
+ device.accessBitmap(false).extractSubset(&subset, src_rect);
// First do a fast downsample by powers of two to get close to the final size.
SkBitmap downsampled_subset =
@@ -657,9 +659,10 @@ bool ChromeRenderViewObserver::CaptureSnapshot(WebView* view,
if (!PaintViewIntoCanvas(view, canvas))
return false;
- SkDevice* device = skia::GetTopDevice(canvas);
+ skia::BitmapPlatformDevice& device =
+ static_cast<skia::BitmapPlatformDevice&>(canvas.getTopPlatformDevice());
- const SkBitmap& bitmap = device->accessBitmap(false);
+ const SkBitmap& bitmap = device.accessBitmap(false);
if (!bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config))
return false;
diff --git a/chrome/renderer/print_web_view_helper_linux.cc b/chrome/renderer/print_web_view_helper_linux.cc
index a5eabfd..c5e8e5a 100644
--- a/chrome/renderer/print_web_view_helper_linux.cc
+++ b/chrome/renderer/print_web_view_helper_linux.cc
@@ -220,7 +220,7 @@ void PrintWebViewHelper::PrintPageInternal(
gfx::Rect content_area(margin_left_in_points, margin_top_in_points,
content_width_in_points, content_height_in_points);
- SkDevice* device = metafile->StartPageForVectorCanvas(
+ skia::PlatformDevice* device = metafile->StartPageForVectorCanvas(
page_size, content_area, 1.0f);
if (!device)
return;
diff --git a/chrome/renderer/print_web_view_helper_win.cc b/chrome/renderer/print_web_view_helper_win.cc
index 5b502c4..4151818 100644
--- a/chrome/renderer/print_web_view_helper_win.cc
+++ b/chrome/renderer/print_web_view_helper_win.cc
@@ -81,7 +81,7 @@ void PrintWebViewHelper::PrintPageInternal(
scoped_ptr<Metafile> metafile(new printing::NativeMetafile);
metafile->Init();
DCHECK(metafile->context());
- skia::InitializeDC(metafile->context());
+ skia::PlatformDevice::InitializeDC(metafile->context());
int page_number = params.page_number;
@@ -228,7 +228,7 @@ void PrintWebViewHelper::RenderPage(
static_cast<int>(margin_top_in_points),
static_cast<int>(content_width_in_points),
static_cast<int>(content_height_in_points));
- SkDevice* device = (*metafile)->StartPageForVectorCanvas(
+ skia::PlatformDevice* device = (*metafile)->StartPageForVectorCanvas(
page_size, content_area, frame->getPrintPageShrink(page_number));
DCHECK(device);
// The printPage method may take a reference to the canvas we pass down, so it
@@ -290,7 +290,7 @@ void PrintWebViewHelper::RenderPage(
metafile2->Init();
HDC hdc = metafile2->context();
DCHECK(hdc);
- skia::InitializeDC(hdc);
+ skia::PlatformDevice::InitializeDC(hdc);
RECT metafile_bounds = (*metafile)->GetPageBounds(1).ToRECT();
// Process the old metafile, placing all non-AlphaBlend calls into the
diff --git a/chrome/renderer/safe_browsing/phishing_thumbnailer.cc b/chrome/renderer/safe_browsing/phishing_thumbnailer.cc
index e8a3b4f..3235ea3 100644
--- a/chrome/renderer/safe_browsing/phishing_thumbnailer.cc
+++ b/chrome/renderer/safe_browsing/phishing_thumbnailer.cc
@@ -8,6 +8,7 @@
#include "base/metrics/histogram.h"
#include "base/time.h"
#include "content/renderer/render_view.h"
+#include "skia/ext/bitmap_platform_device.h"
#include "skia/ext/image_operations.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -52,11 +53,12 @@ SkBitmap GrabPhishingThumbnail(RenderView* render_view,
view->paint(webkit_glue::ToWebCanvas(&canvas),
WebRect(0, 0, view_size.width(), view_size.height()));
- SkDevice* device = skia::GetTopDevice(canvas);
+ skia::BitmapPlatformDevice& device =
+ static_cast<skia::BitmapPlatformDevice&>(canvas.getTopPlatformDevice());
// Now resize the thumbnail to the right size. Note: it is important that we
// use this resize algorithm here.
- const SkBitmap& bitmap = device->accessBitmap(false);
+ const SkBitmap& bitmap = device.accessBitmap(false);
SkBitmap thumbnail = skia::ImageOperations::Resize(
bitmap,
skia::ImageOperations::RESIZE_LANCZOS3,