| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "skia/ext/platform_device.h" | 6 #include "skia/ext/platform_device.h" |
| 7 | 7 |
| 8 #include "third_party/skia/include/core/SkMetaData.h" | 8 #include "third_party/skia/include/core/SkMetaData.h" |
| 9 | 9 |
| 10 namespace skia { | 10 namespace skia { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 const char kDevicePlatformBehaviour[] = "CrDevicePlatformBehaviour"; | 14 const char kDevicePlatformBehaviour[] = "CrDevicePlatformBehaviour"; |
| 15 | 15 |
| 16 #if defined(OS_MACOSX) | 16 #if defined(OS_MACOSX) |
| 17 const char kIsPreviewMetafileKey[] = "CrIsPreviewMetafile"; | 17 const char kIsPreviewMetafileKey[] = "CrIsPreviewMetafile"; |
| 18 #endif | |
| 19 | 18 |
| 20 void SetBoolMetaData(const SkCanvas& canvas, const char* key, bool value) { | 19 void SetBoolMetaData(const SkCanvas& canvas, const char* key, bool value) { |
| 21 SkMetaData& meta = skia::getMetaData(canvas); | 20 SkMetaData& meta = skia::getMetaData(canvas); |
| 22 meta.setBool(key, value); | 21 meta.setBool(key, value); |
| 23 } | 22 } |
| 24 | 23 |
| 25 bool GetBoolMetaData(const SkCanvas& canvas, const char* key) { | 24 bool GetBoolMetaData(const SkCanvas& canvas, const char* key) { |
| 26 bool value; | 25 bool value; |
| 27 SkMetaData& meta = skia::getMetaData(canvas); | 26 SkMetaData& meta = skia::getMetaData(canvas); |
| 28 if (!meta.findBool(key, &value)) | 27 if (!meta.findBool(key, &value)) |
| 29 value = false; | 28 value = false; |
| 30 return value; | 29 return value; |
| 31 } | 30 } |
| 31 #endif |
| 32 | 32 |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 void SetPlatformDevice(SkBaseDevice* device, PlatformDevice* platform_behaviour)
{ | 35 void SetPlatformDevice(SkBaseDevice* device, |
| 36 PlatformDevice* platform_behaviour) { |
| 36 SkMetaData& meta_data = device->getMetaData(); | 37 SkMetaData& meta_data = device->getMetaData(); |
| 37 meta_data.setPtr(kDevicePlatformBehaviour, platform_behaviour); | 38 meta_data.setPtr(kDevicePlatformBehaviour, platform_behaviour); |
| 38 } | 39 } |
| 39 | 40 |
| 40 PlatformDevice* GetPlatformDevice(SkBaseDevice* device) { | 41 PlatformDevice* GetPlatformDevice(SkBaseDevice* device) { |
| 41 if (device) { | 42 if (device) { |
| 42 SkMetaData& meta_data = device->getMetaData(); | 43 SkMetaData& meta_data = device->getMetaData(); |
| 43 PlatformDevice* device_behaviour = NULL; | 44 PlatformDevice* device_behaviour = NULL; |
| 44 if (meta_data.findPtr(kDevicePlatformBehaviour, | 45 if (meta_data.findPtr(kDevicePlatformBehaviour, |
| 45 reinterpret_cast<void**>(&device_behaviour))) | 46 reinterpret_cast<void**>(&device_behaviour))) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 62 bool IsPreviewMetafile(const SkCanvas& canvas) { | 63 bool IsPreviewMetafile(const SkCanvas& canvas) { |
| 63 return GetBoolMetaData(canvas, kIsPreviewMetafileKey); | 64 return GetBoolMetaData(canvas, kIsPreviewMetafileKey); |
| 64 } | 65 } |
| 65 #endif | 66 #endif |
| 66 | 67 |
| 67 bool PlatformDevice::SupportsPlatformPaint() { | 68 bool PlatformDevice::SupportsPlatformPaint() { |
| 68 return true; | 69 return true; |
| 69 } | 70 } |
| 70 | 71 |
| 71 } // namespace skia | 72 } // namespace skia |
| OLD | NEW |