OLD | NEW |
---|---|
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #import <ApplicationServices/ApplicationServices.h> | 9 #import <ApplicationServices/ApplicationServices.h> |
10 #include "third_party/skia/include/core/SkDevice.h" | 10 #include "third_party/skia/include/core/SkDevice.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 // functions. | 21 // functions. |
22 // This class is abstract and must be subclassed. It provides the basic | 22 // This class is abstract and must be subclassed. It provides the basic |
23 // interface to implement it either with or without a bitmap backend. | 23 // interface to implement it either with or without a bitmap backend. |
24 class PlatformDevice : public SkDevice { | 24 class PlatformDevice : public SkDevice { |
25 public: | 25 public: |
26 typedef CGContextRef PlatformSurface; | 26 typedef CGContextRef PlatformSurface; |
27 | 27 |
28 // The CGContext that corresponds to the bitmap, used for CoreGraphics | 28 // The CGContext that corresponds to the bitmap, used for CoreGraphics |
29 // operations drawing into the bitmap. This is possibly heavyweight, so it | 29 // operations drawing into the bitmap. This is possibly heavyweight, so it |
30 // should exist only during one pass of rendering. | 30 // should exist only during one pass of rendering. |
31 virtual CGContextRef GetBitmapContext() = 0; | 31 virtual CGContextRef GetBitmapContext() = 0; |
vandebo (ex-Chrome)
2011/04/05 20:38:49
Is there a reason to keep this method in addition
alokp
2011/04/05 20:49:29
No. I will eventually delete it when I get a mac.
vandebo (ex-Chrome)
2011/04/05 20:59:09
You could probably manage this using a couple roun
| |
32 | 32 |
33 // Draws to the given graphics context. If the bitmap context doesn't exist, | 33 // Draws to the given graphics context. If the bitmap context doesn't exist, |
34 // this will temporarily create it. However, if you have created the bitmap | 34 // this will temporarily create it. However, if you have created the bitmap |
35 // context, it will be more efficient if you don't free it until after this | 35 // context, it will be more efficient if you don't free it until after this |
36 // call so it doesn't have to be created twice. If src_rect is null, then | 36 // call so it doesn't have to be created twice. If src_rect is null, then |
37 // the entirety of the source device will be copied. | 37 // the entirety of the source device will be copied. |
38 virtual void DrawToContext(CGContextRef context, int x, int y, | 38 virtual void DrawToContext(CGContextRef context, int x, int y, |
39 const CGRect* src_rect) = 0; | 39 const CGRect* src_rect) = 0; |
40 | 40 |
41 // Returns if the preferred rendering engine is vectorial or bitmap based. | 41 // Returns if the preferred rendering engine is vectorial or bitmap based. |
42 virtual bool IsVectorial() = 0; | 42 virtual bool IsVectorial() = 0; |
43 | 43 |
44 // Returns if native platform APIs are allowed to render text to this device. | 44 // Returns if native platform APIs are allowed to render text to this device. |
45 virtual bool IsNativeFontRenderingAllowed(); | 45 virtual bool IsNativeFontRenderingAllowed(); |
46 | 46 |
47 virtual PlatformSurface BeginPlatformPaint(); | |
48 virtual void EndPlatformPaint(); | |
49 | |
47 // Initializes the default settings and colors in a device context. | 50 // Initializes the default settings and colors in a device context. |
48 static void InitializeCGContext(CGContextRef context); | 51 static void InitializeCGContext(CGContextRef context); |
49 | 52 |
50 // Loads a SkPath into the CG context. The path can there after be used for | 53 // Loads a SkPath into the CG context. The path can there after be used for |
51 // clipping or as a stroke. | 54 // clipping or as a stroke. |
52 static void LoadPathToCGContext(CGContextRef context, const SkPath& path); | 55 static void LoadPathToCGContext(CGContextRef context, const SkPath& path); |
53 | 56 |
54 // Loads a SkRegion into the CG context. | 57 // Loads a SkRegion into the CG context. |
55 static void LoadClippingRegionToCGContext(CGContextRef context, | 58 static void LoadClippingRegionToCGContext(CGContextRef context, |
56 const SkRegion& region, | 59 const SkRegion& region, |
57 const SkMatrix& transformation); | 60 const SkMatrix& transformation); |
58 | 61 |
59 protected: | 62 protected: |
60 // Forwards |bitmap| to SkDevice's constructor. | 63 // Forwards |bitmap| to SkDevice's constructor. |
61 PlatformDevice(const SkBitmap& bitmap); | 64 PlatformDevice(const SkBitmap& bitmap); |
62 | 65 |
63 // Loads the specified Skia transform into the device context | 66 // Loads the specified Skia transform into the device context |
64 static void LoadTransformToCGContext(CGContextRef context, | 67 static void LoadTransformToCGContext(CGContextRef context, |
65 const SkMatrix& matrix); | 68 const SkMatrix& matrix); |
66 }; | 69 }; |
67 | 70 |
68 } // namespace skia | 71 } // namespace skia |
69 | 72 |
70 #endif // SKIA_EXT_PLATFORM_DEVICE_MAC_H_ | 73 #endif // SKIA_EXT_PLATFORM_DEVICE_MAC_H_ |
71 | 74 |
OLD | NEW |