|
OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "skia/ext/platform_device.h" | |
6 | |
7 #include "third_party/skia/include/core/SkMetaData.h" | |
8 | |
9 namespace skia { | |
10 | |
11 namespace { | |
12 const char* kDevicePlatformBehaviour = "CrDevicePlatformBehaviour"; | |
13 } | |
14 | |
15 void SetPlatformDevice(SkDevice* device, PlatformDevice* platform_behaviour) { | |
16 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.
| |
17 meta_data.setPtr(kDevicePlatformBehaviour, platform_behaviour); | |
18 } | |
19 | |
20 PlatformDevice* GetPlatformDevice(SkDevice* device) { | |
21 SkMetaData& meta_data = device->getMetaData(); | |
22 PlatformDevice* device_behaviour = NULL; | |
23 if (meta_data.findPtr(kDevicePlatformBehaviour, | |
24 reinterpret_cast<void**>(&device_behaviour))) | |
25 return device_behaviour; | |
26 | |
27 return NULL; | |
28 } | |
29 | |
30 PlatformSurface BeginPlatformPaint(SkDevice* device) { | |
31 PlatformDevice* platform_device = GetPlatformDevice(device); | |
32 if (platform_device) | |
33 return platform_device->BeginPlatformPaint(); | |
34 | |
35 return 0; | |
36 } | |
37 | |
38 void EndPlatformPaint(SkDevice* device) { | |
39 PlatformDevice* platform_device = GetPlatformDevice(device); | |
40 if (platform_device) | |
41 return platform_device->EndPlatformPaint(); | |
42 } | |
43 | |
44 bool IsVectorial(SkDevice* device) { | |
45 PlatformDevice* platform_device = GetPlatformDevice(device); | |
46 if (platform_device) | |
47 return platform_device->IsVectorial(); | |
48 | |
49 return device->getDeviceCapabilities() & SkDevice::kVector_Capability; | |
50 } | |
51 | |
52 bool IsNativeFontRenderingAllowed(SkDevice* device) { | |
53 PlatformDevice* platform_device = GetPlatformDevice(device); | |
54 if (platform_device) | |
55 return platform_device->IsNativeFontRenderingAllowed(); | |
56 | |
57 return false; | |
58 } | |
59 | |
60 void DrawToNativeContext(SkDevice* device, PlatformSurface context, | |
61 int x, int y, const PlatformRect* src_rect) { | |
62 PlatformDevice* platform_device = GetPlatformDevice(device); | |
63 if (platform_device) | |
64 platform_device->DrawToNativeContext(context, x, y, src_rect); | |
65 } | |
66 | |
67 } // namespace skia | |
68 | |
OLD | NEW |