| 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 "skia/ext/platform_surface.h" |
| 16 #include "third_party/skia/include/core/SkBitmapDevice.h" | 16 #include "third_party/skia/include/core/SkBitmapDevice.h" |
| 17 #include "third_party/skia/include/core/SkTypes.h" | 17 #include "third_party/skia/include/core/SkTypes.h" |
| 18 | 18 |
| 19 class SkMatrix; | 19 class SkMatrix; |
| 20 class SkMetaData; | |
| 21 class SkPath; | 20 class SkPath; |
| 22 class SkRegion; | 21 class SkRegion; |
| 23 | 22 |
| 24 #if defined(USE_CAIRO) | |
| 25 typedef struct _cairo cairo_t; | |
| 26 typedef struct _cairo_rectangle cairo_rectangle_t; | |
| 27 #elif defined(OS_MACOSX) | |
| 28 typedef struct CGContext* CGContextRef; | |
| 29 typedef struct CGRect CGRect; | |
| 30 #endif | |
| 31 | |
| 32 namespace skia { | 23 namespace skia { |
| 33 | 24 |
| 34 class PlatformDevice; | 25 class PlatformDevice; |
| 35 | 26 |
| 36 #if defined(OS_WIN) | |
| 37 typedef HDC PlatformSurface; | |
| 38 typedef RECT PlatformRect; | |
| 39 #elif defined(USE_CAIRO) | |
| 40 typedef cairo_t* PlatformSurface; | |
| 41 typedef cairo_rectangle_t PlatformRect; | |
| 42 #elif defined(OS_MACOSX) | |
| 43 typedef CGContextRef PlatformSurface; | |
| 44 typedef CGRect PlatformRect; | |
| 45 #else | |
| 46 typedef void* PlatformSurface; | |
| 47 typedef SkIRect* PlatformRect; | |
| 48 #endif | |
| 49 | |
| 50 // The following routines provide accessor points for the functionality | 27 // The following routines provide accessor points for the functionality |
| 51 // exported by the various PlatformDevice ports. | 28 // exported by the various PlatformDevice ports. |
| 52 // All calls to PlatformDevice::* should be routed through these | 29 // All calls to PlatformDevice::* should be routed through these |
| 53 // helper functions. | 30 // helper functions. |
| 54 | 31 |
| 55 // Bind a PlatformDevice instance, |platform_device| to |device|. Subsequent | 32 // Bind a PlatformDevice instance, |platform_device| to |device|. Subsequent |
| 56 // calls to the functions exported below will forward the request to the | 33 // calls to the functions exported below will forward the request to the |
| 57 // corresponding method on the bound PlatformDevice instance. If no | 34 // corresponding method on the bound PlatformDevice instance. If no |
| 58 // PlatformDevice has been bound to the SkBaseDevice passed, then the | 35 // PlatformDevice has been bound to the SkBaseDevice passed, then the |
| 59 // routines are NOPS. | 36 // routines are NOPS. |
| 60 SK_API void SetPlatformDevice(SkBaseDevice* device, | 37 SK_API void SetPlatformDevice(SkBaseDevice* device, |
| 61 PlatformDevice* platform_device); | 38 PlatformDevice* platform_device); |
| 62 SK_API PlatformDevice* GetPlatformDevice(SkBaseDevice* device); | 39 SK_API PlatformDevice* GetPlatformDevice(SkBaseDevice* device); |
| 63 | 40 |
| 64 | 41 |
| 65 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
| 66 // Initializes the default settings and colors in a device context. | 43 // Initializes the default settings and colors in a device context. |
| 67 SK_API void InitializeDC(HDC context); | 44 SK_API void InitializeDC(HDC context); |
| 68 #elif defined(OS_MACOSX) | |
| 69 // Returns the CGContext that backing the SkBaseDevice. Forwards to the bound | |
| 70 // PlatformDevice. Returns NULL if no PlatformDevice is bound. | |
| 71 SK_API CGContextRef GetBitmapContext(SkBaseDevice* device); | |
| 72 #endif | |
| 73 | |
| 74 // Following routines are used in print preview workflow to mark the | |
| 75 // preview metafile. | |
| 76 SK_API SkMetaData& getMetaData(const SkCanvas& canvas); | |
| 77 | |
| 78 #if defined(OS_MACOSX) | |
| 79 SK_API void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview); | |
| 80 SK_API bool IsPreviewMetafile(const SkCanvas& canvas); | |
| 81 #endif | 45 #endif |
| 82 | 46 |
| 83 // A SkBitmapDevice is basically a wrapper around SkBitmap that provides a | 47 // A SkBitmapDevice is basically a wrapper around SkBitmap that provides a |
| 84 // surface for SkCanvas to draw into. PlatformDevice provides a surface | 48 // surface for SkCanvas to draw into. PlatformDevice provides a surface |
| 85 // Windows can also write to. It also provides functionality to play well | 49 // Windows can also write to. It also provides functionality to play well |
| 86 // with GDI drawing functions. This class is abstract and must be subclassed. | 50 // with GDI drawing functions. This class is abstract and must be subclassed. |
| 87 // It provides the basic interface to implement it either with or without | 51 // It provides the basic interface to implement it either with or without |
| 88 // a bitmap backend. | 52 // a bitmap backend. |
| 89 // | 53 // |
| 90 // PlatformDevice provides an interface which sub-classes of SkBaseDevice can | 54 // PlatformDevice provides an interface which sub-classes of SkBaseDevice can |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 static void LoadTransformToDC(HDC dc, const SkMatrix& matrix); | 109 static void LoadTransformToDC(HDC dc, const SkMatrix& matrix); |
| 146 | 110 |
| 147 // Transforms SkPath's paths into a series of cubic path. | 111 // Transforms SkPath's paths into a series of cubic path. |
| 148 static bool SkPathToCubicPaths(CubicPaths* paths, const SkPath& skpath); | 112 static bool SkPathToCubicPaths(CubicPaths* paths, const SkPath& skpath); |
| 149 #endif | 113 #endif |
| 150 }; | 114 }; |
| 151 | 115 |
| 152 } // namespace skia | 116 } // namespace skia |
| 153 | 117 |
| 154 #endif // SKIA_EXT_PLATFORM_DEVICE_H_ | 118 #endif // SKIA_EXT_PLATFORM_DEVICE_H_ |
| OLD | NEW |