| 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) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // A SkDevice is basically a wrapper around SkBitmap that provides a surface for | 89 // A SkDevice is basically a wrapper around SkBitmap that provides a surface for |
| 90 // SkCanvas to draw into. PlatformDevice provides a surface Windows can also | 90 // SkCanvas to draw into. PlatformDevice provides a surface Windows can also |
| 91 // write to. It also provides functionality to play well with GDI drawing | 91 // write to. It also provides functionality to play well with GDI drawing |
| 92 // functions. This class is abstract and must be subclassed. It provides the | 92 // functions. This class is abstract and must be subclassed. It provides the |
| 93 // basic interface to implement it either with or without a bitmap backend. | 93 // basic interface to implement it either with or without a bitmap backend. |
| 94 // | 94 // |
| 95 // PlatformDevice provides an interface which sub-classes of SkDevice can also | 95 // PlatformDevice provides an interface which sub-classes of SkDevice can also |
| 96 // provide to allow for drawing by the native platform into the device. | 96 // provide to allow for drawing by the native platform into the device. |
| 97 class SK_API PlatformDevice { | 97 class SK_API PlatformDevice { |
| 98 public: | 98 public: |
| 99 enum PlatformPaint { |
| 100 // |
| 101 // PlatformPaint Support |
| 102 // |
| 103 // Platform specific paint operations can not be used to draw on the |
| 104 // given canvas. BeginPlatformPaint will return NULL PlatformSurface. |
| 105 PLATFORM_PAINT_UNSUPPORTED, |
| 106 |
| 107 // Platform specific paint operations can be used to draw on the given |
| 108 // canvas without causing an intermediate bitmap to be created. |
| 109 PLATFORM_PAINT_DIRECT, |
| 110 |
| 111 // Platform specific paint operations can be used to draw on the given |
| 112 // canvas but it might cause an intermediate bitmap to be created. |
| 113 // Allocating and setting up an intermediate bitmap can be expensive. |
| 114 // It is recommended to avoid using platform paint if possible when |
| 115 // platform paint support is indirect. |
| 116 PLATFORM_PAINT_INDIRECT |
| 117 }; |
| 118 |
| 99 virtual ~PlatformDevice() {} | 119 virtual ~PlatformDevice() {} |
| 100 | 120 |
| 101 #if defined(OS_MACOSX) | 121 #if defined(OS_MACOSX) |
| 102 // The CGContext that corresponds to the bitmap, used for CoreGraphics | 122 // The CGContext that corresponds to the bitmap, used for CoreGraphics |
| 103 // operations drawing into the bitmap. This is possibly heavyweight, so it | 123 // operations drawing into the bitmap. This is possibly heavyweight, so it |
| 104 // should exist only during one pass of rendering. | 124 // should exist only during one pass of rendering. |
| 105 virtual CGContextRef GetBitmapContext() = 0; | 125 virtual CGContextRef GetBitmapContext() = 0; |
| 106 #endif | 126 #endif |
| 107 | 127 |
| 108 // The DC that corresponds to the bitmap, used for GDI operations drawing | 128 // The DC that corresponds to the bitmap, used for GDI operations drawing |
| 109 // into the bitmap. This is possibly heavyweight, so it should be existant | 129 // into the bitmap. This is possibly heavyweight, so it should be existant |
| 110 // only during one pass of rendering. | 130 // only during one pass of rendering. |
| 111 virtual PlatformSurface BeginPlatformPaint(); | 131 virtual PlatformSurface BeginPlatformPaint(); |
| 112 | 132 |
| 113 // Finish a previous call to beginPlatformPaint. | 133 // Finish a previous call to beginPlatformPaint. |
| 114 virtual void EndPlatformPaint(); | 134 virtual void EndPlatformPaint(); |
| 115 | 135 |
| 116 // Draws to the given screen DC, if the bitmap DC doesn't exist, this will | 136 // Draws to the given screen DC, if the bitmap DC doesn't exist, this will |
| 117 // temporarily create it. However, if you have created the bitmap DC, it will | 137 // temporarily create it. However, if you have created the bitmap DC, it will |
| 118 // be more efficient if you don't free it until after this call so it doesn't | 138 // be more efficient if you don't free it until after this call so it doesn't |
| 119 // have to be created twice. If src_rect is null, then the entirety of the | 139 // have to be created twice. If src_rect is null, then the entirety of the |
| 120 // source device will be copied. | 140 // source device will be copied. |
| 121 virtual void DrawToNativeContext(PlatformSurface surface, int x, int y, | 141 virtual void DrawToNativeContext(PlatformSurface surface, int x, int y, |
| 122 const PlatformRect* src_rect) = 0; | 142 const PlatformRect* src_rect) = 0; |
| 123 | 143 |
| 124 // Returns true if GDI operations can be used for drawing into the bitmap. | 144 // Returns support for platform specific paint operations. |
| 125 virtual bool SupportsPlatformPaint(); | 145 virtual PlatformPaint PlatformPaintSupport(); |
| 126 | 146 |
| 127 #if defined(OS_WIN) | 147 #if defined(OS_WIN) |
| 128 // Loads a SkPath into the GDI context. The path can there after be used for | 148 // Loads a SkPath into the GDI context. The path can there after be used for |
| 129 // clipping or as a stroke. Returns false if the path failed to be loaded. | 149 // clipping or as a stroke. Returns false if the path failed to be loaded. |
| 130 static bool LoadPathToDC(HDC context, const SkPath& path); | 150 static bool LoadPathToDC(HDC context, const SkPath& path); |
| 131 | 151 |
| 132 // Loads a SkRegion into the GDI context. | 152 // Loads a SkRegion into the GDI context. |
| 133 static void LoadClippingRegionToDC(HDC context, const SkRegion& region, | 153 static void LoadClippingRegionToDC(HDC context, const SkRegion& region, |
| 134 const SkMatrix& transformation); | 154 const SkMatrix& transformation); |
| 135 #elif defined(OS_MACOSX) | 155 #elif defined(OS_MACOSX) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 164 #elif defined(OS_MACOSX) | 184 #elif defined(OS_MACOSX) |
| 165 // Loads the specified Skia transform into the device context | 185 // Loads the specified Skia transform into the device context |
| 166 static void LoadTransformToCGContext(CGContextRef context, | 186 static void LoadTransformToCGContext(CGContextRef context, |
| 167 const SkMatrix& matrix); | 187 const SkMatrix& matrix); |
| 168 #endif | 188 #endif |
| 169 }; | 189 }; |
| 170 | 190 |
| 171 } // namespace skia | 191 } // namespace skia |
| 172 | 192 |
| 173 #endif // SKIA_EXT_PLATFORM_DEVICE_H_ | 193 #endif // SKIA_EXT_PLATFORM_DEVICE_H_ |
| OLD | NEW |