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

Unified Diff: skia/ext/platform_canvas.cc

Issue 6914029: We assume that each SkDevice is our custom PlatformDevice. This assumption is not valid when usin... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 8 months 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
« no previous file with comments | « skia/ext/platform_canvas.h ('k') | ui/gfx/native_theme_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/platform_canvas.cc
===================================================================
--- skia/ext/platform_canvas.cc (revision 83722)
+++ skia/ext/platform_canvas.cc (working copy)
@@ -5,13 +5,21 @@
#include "skia/ext/platform_canvas.h"
#include "skia/ext/bitmap_platform_device.h"
+#include "third_party/skia/include/core/SkMetaData.h"
#include "third_party/skia/include/core/SkTypes.h"
namespace {
+static const char* kPlatformDeviceIdentifier = "CrPlatformDevice";
Jeff Timanus 2011/05/04 21:22:47 Style guide nit/question. Does static have any me
+
skia::PlatformDevice* GetTopPlatformDevice(const SkCanvas* canvas) {
- // All of our devices should be our special PlatformDevice.
SkCanvas::LayerIter iter(const_cast<SkCanvas*>(canvas), false);
- return static_cast<skia::PlatformDevice*>(iter.device());
+ SkDevice* device = iter.device();
+ // Check if this device is our custom PlatformDevice.
+ // The custom devices are tagged with meta-data named
+ // kPlatformDeviceIdentifier.
+ SkMetaData& meta_data = device->getMetaData();
+ return meta_data.findBool(kPlatformDeviceIdentifier) ?
+ static_cast<skia::PlatformDevice*>(device) : NULL;
}
}
@@ -38,10 +46,15 @@
return 4 * width;
}
-bool PlatformCanvas::initializeWithDevice(SkDevice* device) {
+bool PlatformCanvas::initializeWithDevice(PlatformDevice* device) {
if (!device)
return false;
+ // Set meta-data on the device indicating that this device is our custom
+ // platform device.
+ SkMetaData& meta_data = device->getMetaData();
+ meta_data.setBool(kPlatformDeviceIdentifier, true);
+
setDevice(device);
device->unref(); // Was created with refcount 1, and setDevice also refs.
return true;
@@ -52,9 +65,8 @@
}
bool SupportsPlatformPaint(const SkCanvas* canvas) {
- // TODO(alokp): Rename PlatformDevice::IsNativeFontRenderingAllowed after
- // removing these calls from WebKit.
- return GetTopPlatformDevice(canvas)->IsNativeFontRenderingAllowed();
+ skia::PlatformDevice* device = GetTopPlatformDevice(canvas);
+ return device ? device->IsNativeFontRenderingAllowed() : false;
}
PlatformDevice::PlatformSurface BeginPlatformPaint(SkCanvas* canvas) {
« no previous file with comments | « skia/ext/platform_canvas.h ('k') | ui/gfx/native_theme_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698