| 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_CANVAS_H_ | 5 #ifndef SKIA_EXT_PLATFORM_CANVAS_H_ |
| 6 #define SKIA_EXT_PLATFORM_CANVAS_H_ | 6 #define SKIA_EXT_PLATFORM_CANVAS_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // canvas. All writes to the pixmap should be visible if the canvas is | 116 // canvas. All writes to the pixmap should be visible if the canvas is |
| 117 // raster-backed. | 117 // raster-backed. |
| 118 // | 118 // |
| 119 // Returns false on failure: if either argument is nullptr, or if the | 119 // Returns false on failure: if either argument is nullptr, or if the |
| 120 // pixels can not be retrieved from the canvas. In the latter case resets | 120 // pixels can not be retrieved from the canvas. In the latter case resets |
| 121 // the pixmap to empty. | 121 // the pixmap to empty. |
| 122 SK_API bool GetWritablePixels(SkCanvas* canvas, SkPixmap* pixmap); | 122 SK_API bool GetWritablePixels(SkCanvas* canvas, SkPixmap* pixmap); |
| 123 | 123 |
| 124 // Returns true if native platform routines can be used to draw on the | 124 // Returns true if native platform routines can be used to draw on the |
| 125 // given canvas. If this function returns false, | 125 // given canvas. If this function returns false, |
| 126 // ScopedPlatformPaint::GetNativeDrawingContext() should return NULL. | 126 // GetNativeDrawingContext() should return NULL. |
| 127 SK_API bool SupportsPlatformPaint(const SkCanvas* canvas); | 127 SK_API bool SupportsPlatformPaint(const SkCanvas* canvas); |
| 128 | 128 |
| 129 // This object guards calls to platform drawing routines. The surface | 129 // Returns the NativeDrawingContext to use for native platform drawing calls. |
| 130 // returned from GetNativeDrawingContext() can be used with the native platform | 130 SK_API NativeDrawingContext GetNativeDrawingContext(SkCanvas* canvas); |
| 131 // routines. | |
| 132 class SK_API ScopedPlatformPaint { | |
| 133 public: | |
| 134 explicit ScopedPlatformPaint(SkCanvas* canvas); | |
| 135 | |
| 136 // Returns the NativeDrawingContext to use for native platform drawing calls. | |
| 137 NativeDrawingContext GetNativeDrawingContext() { | |
| 138 return native_drawing_context_; | |
| 139 } | |
| 140 | |
| 141 private: | |
| 142 SkCanvas* canvas_; | |
| 143 NativeDrawingContext native_drawing_context_; | |
| 144 | |
| 145 // Disallow copy and assign | |
| 146 ScopedPlatformPaint(const ScopedPlatformPaint&); | |
| 147 ScopedPlatformPaint& operator=(const ScopedPlatformPaint&); | |
| 148 }; | |
| 149 | 131 |
| 150 // Following routines are used in print preview workflow to mark the | 132 // Following routines are used in print preview workflow to mark the |
| 151 // preview metafile. | 133 // preview metafile. |
| 152 SK_API SkMetaData& GetMetaData(const SkCanvas& canvas); | 134 SK_API SkMetaData& GetMetaData(const SkCanvas& canvas); |
| 153 | 135 |
| 154 #if defined(OS_MACOSX) | 136 #if defined(OS_MACOSX) |
| 155 SK_API void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview); | 137 SK_API void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview); |
| 156 SK_API bool IsPreviewMetafile(const SkCanvas& canvas); | 138 SK_API bool IsPreviewMetafile(const SkCanvas& canvas); |
| 157 #endif | 139 #endif |
| 158 | 140 |
| 159 } // namespace skia | 141 } // namespace skia |
| 160 | 142 |
| 161 #endif // SKIA_EXT_PLATFORM_CANVAS_H_ | 143 #endif // SKIA_EXT_PLATFORM_CANVAS_H_ |
| OLD | NEW |