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 #ifndef SKIA_EXT_PLATFORM_DEVICE_MAC_H_ | 5 #ifndef SKIA_EXT_PLATFORM_DEVICE_MAC_H_ |
6 #define SKIA_EXT_PLATFORM_DEVICE_MAC_H_ | 6 #define SKIA_EXT_PLATFORM_DEVICE_MAC_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "third_party/skia/include/core/SkDevice.h" | 9 #include "third_party/skia/include/core/SkDevice.h" |
10 | 10 |
11 typedef struct CGContext* CGContextRef; | 11 typedef struct CGContext* CGContextRef; |
12 typedef struct CGRect CGRect; | 12 typedef struct CGRect CGRect; |
13 | 13 |
14 class SkMatrix; | 14 class SkMatrix; |
15 class SkPath; | 15 class SkPath; |
16 class SkRegion; | 16 class SkRegion; |
17 | 17 |
18 namespace skia { | 18 namespace skia { |
19 | 19 |
20 // Returns the CGContext that backing the SkDevice. Forwards to the bound | 20 // Returns the CGContext that backing the SkDevice. Forwards to the bound |
21 // PlatformDevice. Returns NULL if no PlatformDevice is bound. | 21 // PlatformDevice. Returns NULL if no PlatformDevice is bound. |
22 SK_API CGContextRef GetBitmapContext(SkDevice* device); | 22 SK_API CGContextRef GetBitmapContext(SkDevice* device); |
23 | 23 |
24 // A device is basically a wrapper around SkBitmap that provides a surface for | 24 // A device is basically a wrapper around SkBitmap that provides a surface for |
25 // SkCanvas to draw into. Our device provides a surface CoreGraphics can also | 25 // SkCanvas to draw into. Our device provides a surface CoreGraphics can also |
26 // write to. It also provides functionality to play well with CG drawing | 26 // write to. It also provides functionality to play well with CG drawing |
27 // functions. | 27 // functions. |
28 // This class is abstract and must be subclassed. It provides the basic | 28 // This class is abstract and must be subclassed. It provides the basic |
29 // interface to implement it either with or without a bitmap backend. | 29 // interface to implement it either with or without a bitmap backend. |
30 class PlatformDevice : public SkDevice { | 30 class PlatformDevice { |
31 public: | 31 public: |
32 typedef CGContextRef PlatformSurface; | 32 typedef CGContextRef PlatformSurface; |
33 | 33 |
34 // The CGContext that corresponds to the bitmap, used for CoreGraphics | 34 // The CGContext that corresponds to the bitmap, used for CoreGraphics |
35 // operations drawing into the bitmap. This is possibly heavyweight, so it | 35 // operations drawing into the bitmap. This is possibly heavyweight, so it |
36 // should exist only during one pass of rendering. | 36 // should exist only during one pass of rendering. |
37 virtual CGContextRef GetBitmapContext() = 0; | 37 virtual CGContextRef GetBitmapContext() = 0; |
38 | 38 |
39 // Draws to the given graphics context. If the bitmap context doesn't exist, | 39 // Draws to the given graphics context. If the bitmap context doesn't exist, |
40 // this will temporarily create it. However, if you have created the bitmap | 40 // this will temporarily create it. However, if you have created the bitmap |
(...skipping 18 matching lines...) Expand all Loading... |
59 // Loads a SkPath into the CG context. The path can there after be used for | 59 // Loads a SkPath into the CG context. The path can there after be used for |
60 // clipping or as a stroke. | 60 // clipping or as a stroke. |
61 static void LoadPathToCGContext(CGContextRef context, const SkPath& path); | 61 static void LoadPathToCGContext(CGContextRef context, const SkPath& path); |
62 | 62 |
63 // Loads a SkRegion into the CG context. | 63 // Loads a SkRegion into the CG context. |
64 static void LoadClippingRegionToCGContext(CGContextRef context, | 64 static void LoadClippingRegionToCGContext(CGContextRef context, |
65 const SkRegion& region, | 65 const SkRegion& region, |
66 const SkMatrix& transformation); | 66 const SkMatrix& transformation); |
67 | 67 |
68 protected: | 68 protected: |
69 // Forwards |bitmap| to SkDevice's constructor. | 69 PlatformDevice(SkDevice* device); |
70 PlatformDevice(const SkBitmap& bitmap); | |
71 | 70 |
72 // Loads the specified Skia transform into the device context | 71 // Loads the specified Skia transform into the device context |
73 static void LoadTransformToCGContext(CGContextRef context, | 72 static void LoadTransformToCGContext(CGContextRef context, |
74 const SkMatrix& matrix); | 73 const SkMatrix& matrix); |
| 74 |
| 75 SkDevice* device_; |
75 }; | 76 }; |
76 | 77 |
77 } // namespace skia | 78 } // namespace skia |
78 | 79 |
79 #endif // SKIA_EXT_PLATFORM_DEVICE_MAC_H_ | 80 #endif // SKIA_EXT_PLATFORM_DEVICE_MAC_H_ |
80 | 81 |
OLD | NEW |