| 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 "skia/ext/platform_canvas.h" |
| 15 #include "skia/ext/platform_surface.h" | 16 #include "skia/ext/platform_surface.h" |
| 16 #include "third_party/skia/include/core/SkBitmapDevice.h" | 17 #include "third_party/skia/include/core/SkBitmapDevice.h" |
| 17 #include "third_party/skia/include/core/SkTypes.h" | 18 #include "third_party/skia/include/core/SkTypes.h" |
| 18 | 19 |
| 19 class SkMatrix; | 20 class SkMatrix; |
| 20 class SkPath; | 21 class SkPath; |
| 21 class SkRegion; | 22 class SkRegion; |
| 22 | 23 |
| 23 namespace skia { | 24 namespace skia { |
| 24 | 25 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 54 public: | 55 public: |
| 55 virtual ~PlatformDevice() {} | 56 virtual ~PlatformDevice() {} |
| 56 | 57 |
| 57 #if defined(OS_MACOSX) | 58 #if defined(OS_MACOSX) |
| 58 // The CGContext that corresponds to the bitmap, used for CoreGraphics | 59 // The CGContext that corresponds to the bitmap, used for CoreGraphics |
| 59 // operations drawing into the bitmap. This is possibly heavyweight, so it | 60 // operations drawing into the bitmap. This is possibly heavyweight, so it |
| 60 // should exist only during one pass of rendering. | 61 // should exist only during one pass of rendering. |
| 61 virtual CGContextRef GetBitmapContext() = 0; | 62 virtual CGContextRef GetBitmapContext() = 0; |
| 62 #endif | 63 #endif |
| 63 | 64 |
| 64 // The DC that corresponds to the bitmap, used for GDI operations drawing | |
| 65 // into the bitmap. This is possibly heavyweight, so it should be existant | |
| 66 // only during one pass of rendering. | |
| 67 virtual PlatformSurface BeginPlatformPaint(); | |
| 68 | |
| 69 // Finish a previous call to beginPlatformPaint. | |
| 70 virtual void EndPlatformPaint(); | |
| 71 | |
| 72 #if defined(OS_WIN) | 65 #if defined(OS_WIN) |
| 73 // Loads a SkPath into the GDI context. The path can there after be used for | 66 // Loads a SkPath into the GDI context. The path can there after be used for |
| 74 // clipping or as a stroke. Returns false if the path failed to be loaded. | 67 // clipping or as a stroke. Returns false if the path failed to be loaded. |
| 75 static bool LoadPathToDC(HDC context, const SkPath& path); | 68 static bool LoadPathToDC(HDC context, const SkPath& path); |
| 76 | 69 |
| 77 // Loads a SkRegion into the GDI context. | 70 // Loads a SkRegion into the GDI context. |
| 78 static void LoadClippingRegionToDC(HDC context, const SkRegion& region, | 71 static void LoadClippingRegionToDC(HDC context, const SkRegion& region, |
| 79 const SkMatrix& transformation); | 72 const SkMatrix& transformation); |
| 80 | 73 |
| 81 // Draws to the given screen DC, if the bitmap DC doesn't exist, this will | 74 // Draws to the given screen DC, if the bitmap DC doesn't exist, this will |
| 82 // temporarily create it. However, if you have created the bitmap DC, it will | 75 // temporarily create it. However, if you have created the bitmap DC, it will |
| 83 // be more efficient if you don't free it until after this call so it doesn't | 76 // be more efficient if you don't free it until after this call so it doesn't |
| 84 // have to be created twice. If src_rect is null, then the entirety of the | 77 // have to be created twice. If src_rect is null, then the entirety of the |
| 85 // source device will be copied. | 78 // source device will be copied. |
| 86 virtual void DrawToHDC(HDC, int x, int y, const RECT* src_rect); | 79 virtual void DrawToHDC(HDC, int x, int y, const RECT* src_rect); |
| 87 #endif | 80 #endif |
| 88 | 81 |
| 89 protected: | 82 protected: |
| 83 // The DC that corresponds to the bitmap, used for GDI operations drawing |
| 84 // into the bitmap. This is possibly heavyweight, so it should be existant |
| 85 // only during one pass of rendering. |
| 86 virtual PlatformSurface BeginPlatformPaint(); |
| 87 |
| 90 #if defined(OS_WIN) | 88 #if defined(OS_WIN) |
| 91 // Arrays must be inside structures. | 89 // Arrays must be inside structures. |
| 92 struct CubicPoints { | 90 struct CubicPoints { |
| 93 SkPoint p[4]; | 91 SkPoint p[4]; |
| 94 }; | 92 }; |
| 95 typedef std::vector<CubicPoints> CubicPath; | 93 typedef std::vector<CubicPoints> CubicPath; |
| 96 typedef std::vector<CubicPath> CubicPaths; | 94 typedef std::vector<CubicPath> CubicPaths; |
| 97 | 95 |
| 98 // Loads the specified Skia transform into the device context, excluding | 96 // Loads the specified Skia transform into the device context, excluding |
| 99 // perspective (which GDI doesn't support). | 97 // perspective (which GDI doesn't support). |
| 100 static void LoadTransformToDC(HDC dc, const SkMatrix& matrix); | 98 static void LoadTransformToDC(HDC dc, const SkMatrix& matrix); |
| 101 | 99 |
| 102 // Transforms SkPath's paths into a series of cubic path. | 100 // Transforms SkPath's paths into a series of cubic path. |
| 103 static bool SkPathToCubicPaths(CubicPaths* paths, const SkPath& skpath); | 101 static bool SkPathToCubicPaths(CubicPaths* paths, const SkPath& skpath); |
| 104 #endif | 102 #endif |
| 103 |
| 104 friend class skia::ScopedPlatformPaint; |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 } // namespace skia | 107 } // namespace skia |
| 108 | 108 |
| 109 #endif // SKIA_EXT_PLATFORM_DEVICE_H_ | 109 #endif // SKIA_EXT_PLATFORM_DEVICE_H_ |
| OLD | NEW |