| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_H_ | 5 #ifndef SKIA_EXT_PLATFORM_DEVICE_H_ |
| 6 #define SKIA_EXT_PLATFORM_DEVICE_H_ | 6 #define SKIA_EXT_PLATFORM_DEVICE_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| 11 #include <windows.h> | 11 #include <windows.h> |
| 12 #include <vector> | 12 #include <vector> |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 #include "third_party/skia/include/core/SkColor.h" | 15 #include "third_party/skia/include/core/SkColor.h" |
| 16 #include "third_party/skia/include/core/SkDevice.h" | 16 #include "third_party/skia/include/core/SkBitmapDevice.h" |
| 17 #include "third_party/skia/include/core/SkPreConfig.h" | 17 #include "third_party/skia/include/core/SkPreConfig.h" |
| 18 | 18 |
| 19 class SkMatrix; | 19 class SkMatrix; |
| 20 class SkMetaData; | 20 class SkMetaData; |
| 21 class SkPath; | 21 class SkPath; |
| 22 class SkRegion; | 22 class SkRegion; |
| 23 | 23 |
| 24 #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_FREEBSD) \ | 24 #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_FREEBSD) \ |
| 25 || defined(OS_SOLARIS) | 25 || defined(OS_SOLARIS) |
| 26 typedef struct _cairo cairo_t; | 26 typedef struct _cairo cairo_t; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 43 #elif defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_FREEBSD) \ | 43 #elif defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_FREEBSD) \ |
| 44 || defined(OS_SOLARIS) | 44 || defined(OS_SOLARIS) |
| 45 typedef cairo_t* PlatformSurface; | 45 typedef cairo_t* PlatformSurface; |
| 46 typedef cairo_rectangle_t PlatformRect; | 46 typedef cairo_rectangle_t PlatformRect; |
| 47 #elif defined(OS_MACOSX) | 47 #elif defined(OS_MACOSX) |
| 48 typedef CGContextRef PlatformSurface; | 48 typedef CGContextRef PlatformSurface; |
| 49 typedef CGRect PlatformRect; | 49 typedef CGRect PlatformRect; |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 // The following routines provide accessor points for the functionality | 52 // The following routines provide accessor points for the functionality |
| 53 // exported by the various PlatformDevice ports. The PlatformDevice, and | 53 // exported by the various PlatformDevice ports. |
| 54 // BitmapPlatformDevice classes inherit directly from SkDevice, which is no | 54 // All calls to PlatformDevice::* should be routed through these |
| 55 // longer a supported usage-pattern for skia. In preparation of the removal of | |
| 56 // these classes, all calls to PlatformDevice::* should be routed through these | |
| 57 // helper functions. | 55 // helper functions. |
| 58 | 56 |
| 59 // Bind a PlatformDevice instance, |platform_device| to |device|. Subsequent | 57 // Bind a PlatformDevice instance, |platform_device| to |device|. Subsequent |
| 60 // calls to the functions exported below will forward the request to the | 58 // calls to the functions exported below will forward the request to the |
| 61 // corresponding method on the bound PlatformDevice instance. If no | 59 // corresponding method on the bound PlatformDevice instance. If no |
| 62 // PlatformDevice has been bound to the SkDevice passed, then the routines are | 60 // PlatformDevice has been bound to the SkBaseDevice passed, then the |
| 63 // NOPS. | 61 // routines are NOPS. |
| 64 SK_API void SetPlatformDevice(SkDevice* device, | 62 SK_API void SetPlatformDevice(SkBaseDevice* device, |
| 65 PlatformDevice* platform_device); | 63 PlatformDevice* platform_device); |
| 66 SK_API PlatformDevice* GetPlatformDevice(SkDevice* device); | 64 SK_API PlatformDevice* GetPlatformDevice(SkBaseDevice* device); |
| 67 | 65 |
| 68 | 66 |
| 69 #if defined(OS_WIN) | 67 #if defined(OS_WIN) |
| 70 // Initializes the default settings and colors in a device context. | 68 // Initializes the default settings and colors in a device context. |
| 71 SK_API void InitializeDC(HDC context); | 69 SK_API void InitializeDC(HDC context); |
| 72 #elif defined(OS_MACOSX) | 70 #elif defined(OS_MACOSX) |
| 73 // Returns the CGContext that backing the SkDevice. Forwards to the bound | 71 // Returns the CGContext that backing the SkBaseDevice. Forwards to the bound |
| 74 // PlatformDevice. Returns NULL if no PlatformDevice is bound. | 72 // PlatformDevice. Returns NULL if no PlatformDevice is bound. |
| 75 SK_API CGContextRef GetBitmapContext(SkDevice* device); | 73 SK_API CGContextRef GetBitmapContext(SkBaseDevice* device); |
| 76 #endif | 74 #endif |
| 77 | 75 |
| 78 // Following routines are used in print preview workflow to mark the draft mode | 76 // Following routines are used in print preview workflow to mark the draft mode |
| 79 // metafile and preview metafile. | 77 // metafile and preview metafile. |
| 80 SK_API SkMetaData& getMetaData(const SkCanvas& canvas); | 78 SK_API SkMetaData& getMetaData(const SkCanvas& canvas); |
| 81 SK_API void SetIsDraftMode(const SkCanvas& canvas, bool draft_mode); | 79 SK_API void SetIsDraftMode(const SkCanvas& canvas, bool draft_mode); |
| 82 SK_API bool IsDraftMode(const SkCanvas& canvas); | 80 SK_API bool IsDraftMode(const SkCanvas& canvas); |
| 83 | 81 |
| 84 #if defined(OS_MACOSX) || defined(OS_WIN) | 82 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 85 SK_API void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview); | 83 SK_API void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview); |
| 86 SK_API bool IsPreviewMetafile(const SkCanvas& canvas); | 84 SK_API bool IsPreviewMetafile(const SkCanvas& canvas); |
| 87 #endif | 85 #endif |
| 88 | 86 |
| 89 // A SkDevice is basically a wrapper around SkBitmap that provides a surface for | 87 // A SkBitmapDevice is basically a wrapper around SkBitmap that provides a |
| 90 // SkCanvas to draw into. PlatformDevice provides a surface Windows can also | 88 // surface for SkCanvas to draw into. PlatformDevice provides a surface |
| 91 // write to. It also provides functionality to play well with GDI drawing | 89 // Windows can also write to. It also provides functionality to play well |
| 92 // functions. This class is abstract and must be subclassed. It provides the | 90 // with GDI drawing functions. This class is abstract and must be subclassed. |
| 93 // basic interface to implement it either with or without a bitmap backend. | 91 // It provides the basic interface to implement it either with or without |
| 92 // a bitmap backend. |
| 94 // | 93 // |
| 95 // PlatformDevice provides an interface which sub-classes of SkDevice can also | 94 // PlatformDevice provides an interface which sub-classes of SkBaseDevice can |
| 96 // provide to allow for drawing by the native platform into the device. | 95 // also provide to allow for drawing by the native platform into the device. |
| 96 // TODO(robertphillips): Once the bitmap-specific entry points are removed |
| 97 // from SkBaseDevice it might make sense for PlatformDevice to be derived |
| 98 // from it. |
| 97 class SK_API PlatformDevice { | 99 class SK_API PlatformDevice { |
| 98 public: | 100 public: |
| 99 virtual ~PlatformDevice() {} | 101 virtual ~PlatformDevice() {} |
| 100 | 102 |
| 101 #if defined(OS_MACOSX) | 103 #if defined(OS_MACOSX) |
| 102 // The CGContext that corresponds to the bitmap, used for CoreGraphics | 104 // The CGContext that corresponds to the bitmap, used for CoreGraphics |
| 103 // operations drawing into the bitmap. This is possibly heavyweight, so it | 105 // operations drawing into the bitmap. This is possibly heavyweight, so it |
| 104 // should exist only during one pass of rendering. | 106 // should exist only during one pass of rendering. |
| 105 virtual CGContextRef GetBitmapContext() = 0; | 107 virtual CGContextRef GetBitmapContext() = 0; |
| 106 #endif | 108 #endif |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 #elif defined(OS_MACOSX) | 166 #elif defined(OS_MACOSX) |
| 165 // Loads the specified Skia transform into the device context | 167 // Loads the specified Skia transform into the device context |
| 166 static void LoadTransformToCGContext(CGContextRef context, | 168 static void LoadTransformToCGContext(CGContextRef context, |
| 167 const SkMatrix& matrix); | 169 const SkMatrix& matrix); |
| 168 #endif | 170 #endif |
| 169 }; | 171 }; |
| 170 | 172 |
| 171 } // namespace skia | 173 } // namespace skia |
| 172 | 174 |
| 173 #endif // SKIA_EXT_PLATFORM_DEVICE_H_ | 175 #endif // SKIA_EXT_PLATFORM_DEVICE_H_ |
| OLD | NEW |