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

Unified Diff: skia/ext/platform_device.cc

Issue 7019013: Removal of dependencies on PlatformDevice classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Addressing comments. Created 9 years, 7 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
Index: skia/ext/platform_device.cc
===================================================================
--- skia/ext/platform_device.cc (revision 0)
+++ skia/ext/platform_device.cc (revision 0)
@@ -0,0 +1,68 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "skia/ext/platform_device.h"
+
+#include "third_party/skia/include/core/SkMetaData.h"
+
+namespace skia {
+
+namespace {
+const char* kDevicePlatformBehaviour = "CrDevicePlatformBehaviour";
+}
+
+void SetPlatformDevice(SkDevice* device, PlatformDevice* platform_behaviour) {
+ SkMetaData& meta_data = device->getMetaData();
alokp 2011/05/19 18:15:15 This is still a bit confusing but OK for the first
Jeff Timanus 2011/05/19 20:38:29 The reason I place the meta-data here is so that a
alokp 2011/05/19 21:52:27 Yes. A PlatformData class would be perfect.
+ meta_data.setPtr(kDevicePlatformBehaviour, platform_behaviour);
+}
+
+PlatformDevice* GetPlatformDevice(SkDevice* device) {
+ SkMetaData& meta_data = device->getMetaData();
+ PlatformDevice* device_behaviour = NULL;
+ if (meta_data.findPtr(kDevicePlatformBehaviour,
+ reinterpret_cast<void**>(&device_behaviour)))
+ return device_behaviour;
+
+ return NULL;
+}
+
+PlatformSurface BeginPlatformPaint(SkDevice* device) {
+ PlatformDevice* platform_device = GetPlatformDevice(device);
+ if (platform_device)
+ return platform_device->BeginPlatformPaint();
+
+ return 0;
+}
+
+void EndPlatformPaint(SkDevice* device) {
+ PlatformDevice* platform_device = GetPlatformDevice(device);
+ if (platform_device)
+ return platform_device->EndPlatformPaint();
+}
+
+bool IsVectorial(SkDevice* device) {
+ PlatformDevice* platform_device = GetPlatformDevice(device);
+ if (platform_device)
+ return platform_device->IsVectorial();
+
+ return device->getDeviceCapabilities() & SkDevice::kVector_Capability;
+}
+
+bool IsNativeFontRenderingAllowed(SkDevice* device) {
+ PlatformDevice* platform_device = GetPlatformDevice(device);
+ if (platform_device)
+ return platform_device->IsNativeFontRenderingAllowed();
+
+ return false;
+}
+
+void DrawToNativeContext(SkDevice* device, PlatformSurface context,
+ int x, int y, const PlatformRect* src_rect) {
+ PlatformDevice* platform_device = GetPlatformDevice(device);
+ if (platform_device)
+ platform_device->DrawToNativeContext(context, x, y, src_rect);
+}
+
+} // namespace skia
+
Property changes on: skia\ext\platform_device.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698