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

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: Remove unnecessary headers. 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,73 @@
+// 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 platform_util {
+
+namespace {
+const char* kDevicePlatformBehaviour = "CrDevicePlatformBehaviour";
+}
+
+void SetPlatformDevice(SkDevice* device, PlatformDevice* platform_behaviour) {
+ SkMetaData& meta_data = device->getMetaData();
+ 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();
+}
+
+// Returns the color value at the specified location.
+SkColor GetColorAt(SkDevice* device, int x, int y) {
+ const SkBitmap& bitmap = device->accessBitmap(false);
+ SkAutoLockPixels lock(bitmap);
+ uint32_t* data = bitmap.getAddr32(0, 0);
+ return static_cast<SkColor>(data[x + y * device->width()]);
+}
+
+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;
+}
+
+} // namespace platform_util
+
+} // namespace skia
+
Property changes on: skia\ext\platform_device.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698