| 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 |
| 11 // The platform-specific device will include the necessary platform headers | 11 // The platform-specific device will include the necessary platform headers |
| 12 // to get the surface type. | 12 // to get the surface type. |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "skia/ext/platform_surface.h" | 14 #include "skia/ext/native_drawing_context.h" |
| 15 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
| 16 #include "third_party/skia/include/core/SkCanvas.h" | 16 #include "third_party/skia/include/core/SkCanvas.h" |
| 17 #include "third_party/skia/include/core/SkPixelRef.h" | 17 #include "third_party/skia/include/core/SkPixelRef.h" |
| 18 #include "third_party/skia/include/core/SkPixmap.h" | 18 #include "third_party/skia/include/core/SkPixmap.h" |
| 19 | 19 |
| 20 class SkBaseDevice; | 20 class SkBaseDevice; |
| 21 | 21 |
| 22 // A PlatformCanvas is a software-rasterized SkCanvas which is *also* | 22 // A PlatformCanvas is a software-rasterized SkCanvas which is *also* |
| 23 // addressable by the platform-specific drawing API (GDI, Core Graphics, | 23 // addressable by the platform-specific drawing API (GDI, Core Graphics, |
| 24 // Cairo...). | 24 // Cairo...). |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // canvas. All writes to the pixmap should be visible if the canvas is | 123 // canvas. All writes to the pixmap should be visible if the canvas is |
| 124 // raster-backed. | 124 // raster-backed. |
| 125 // | 125 // |
| 126 // Returns false on failure: if either argument is nullptr, or if the | 126 // Returns false on failure: if either argument is nullptr, or if the |
| 127 // pixels can not be retrieved from the canvas. In the latter case resets | 127 // pixels can not be retrieved from the canvas. In the latter case resets |
| 128 // the pixmap to empty. | 128 // the pixmap to empty. |
| 129 SK_API bool GetWritablePixels(SkCanvas* canvas, SkPixmap* pixmap); | 129 SK_API bool GetWritablePixels(SkCanvas* canvas, SkPixmap* pixmap); |
| 130 | 130 |
| 131 // Returns true if native platform routines can be used to draw on the | 131 // Returns true if native platform routines can be used to draw on the |
| 132 // given canvas. If this function returns false, | 132 // given canvas. If this function returns false, |
| 133 // ScopedPlatformPaint::GetPlatformSurface() should return NULL. | 133 // ScopedPlatformPaint::GetNativeDrawingContext() should return NULL. |
| 134 SK_API bool SupportsPlatformPaint(const SkCanvas* canvas); | 134 SK_API bool SupportsPlatformPaint(const SkCanvas* canvas); |
| 135 | 135 |
| 136 // This object guards calls to platform drawing routines. The surface | 136 // This object guards calls to platform drawing routines. The surface |
| 137 // returned from GetPlatformSurface() can be used with the native platform | 137 // returned from GetNativeDrawingContext() can be used with the native platform |
| 138 // routines. | 138 // routines. |
| 139 class SK_API ScopedPlatformPaint { | 139 class SK_API ScopedPlatformPaint { |
| 140 public: | 140 public: |
| 141 explicit ScopedPlatformPaint(SkCanvas* canvas); | 141 explicit ScopedPlatformPaint(SkCanvas* canvas); |
| 142 | 142 |
| 143 // Returns the PlatformSurface to use for native platform drawing calls. | 143 // Returns the NativeDrawingContext to use for native platform drawing calls. |
| 144 PlatformSurface GetPlatformSurface() { return platform_surface_; } | 144 NativeDrawingContext GetNativeDrawingContext() { |
| 145 return native_drawing_context_; |
| 146 } |
| 145 | 147 |
| 146 private: | 148 private: |
| 147 SkCanvas* canvas_; | 149 SkCanvas* canvas_; |
| 148 PlatformSurface platform_surface_; | 150 NativeDrawingContext native_drawing_context_; |
| 149 | 151 |
| 150 // Disallow copy and assign | 152 // Disallow copy and assign |
| 151 ScopedPlatformPaint(const ScopedPlatformPaint&); | 153 ScopedPlatformPaint(const ScopedPlatformPaint&); |
| 152 ScopedPlatformPaint& operator=(const ScopedPlatformPaint&); | 154 ScopedPlatformPaint& operator=(const ScopedPlatformPaint&); |
| 153 }; | 155 }; |
| 154 | 156 |
| 155 // Following routines are used in print preview workflow to mark the | 157 // Following routines are used in print preview workflow to mark the |
| 156 // preview metafile. | 158 // preview metafile. |
| 157 SK_API SkMetaData& GetMetaData(const SkCanvas& canvas); | 159 SK_API SkMetaData& GetMetaData(const SkCanvas& canvas); |
| 158 | 160 |
| 159 #if defined(OS_MACOSX) | 161 #if defined(OS_MACOSX) |
| 160 SK_API void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview); | 162 SK_API void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview); |
| 161 SK_API bool IsPreviewMetafile(const SkCanvas& canvas); | 163 SK_API bool IsPreviewMetafile(const SkCanvas& canvas); |
| 162 | 164 |
| 163 // Returns the CGContext that backing the SkCanvas. | 165 // Returns the CGContext that backing the SkCanvas. |
| 164 // Returns NULL if none is bound. | 166 // Returns NULL if none is bound. |
| 165 SK_API CGContextRef GetBitmapContext(const SkCanvas& canvas); | 167 SK_API CGContextRef GetBitmapContext(const SkCanvas& canvas); |
| 166 #endif | 168 #endif |
| 167 | 169 |
| 168 } // namespace skia | 170 } // namespace skia |
| 169 | 171 |
| 170 #endif // SKIA_EXT_PLATFORM_CANVAS_H_ | 172 #endif // SKIA_EXT_PLATFORM_CANVAS_H_ |
| OLD | NEW |