OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_SKIA_UTILS_WIN_H_ | 5 #ifndef SKIA_EXT_SKIA_UTILS_WIN_H_ |
6 #define SKIA_EXT_SKIA_UTILS_WIN_H_ | 6 #define SKIA_EXT_SKIA_UTILS_WIN_H_ |
7 | 7 |
| 8 #include "third_party/skia/include/core/SkBitmap.h" |
8 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
9 #include "third_party/skia/include/core/SkMatrix.h" | 10 #include "third_party/skia/include/core/SkMatrix.h" |
| 11 #include "third_party/skia/include/core/SkRefCnt.h" |
10 | 12 |
11 #include "build/build_config.h" | 13 #include "build/build_config.h" |
12 #include <windows.h> | 14 #include <windows.h> |
13 | 15 |
14 struct SkIRect; | 16 struct SkIRect; |
15 struct SkPoint; | 17 struct SkPoint; |
16 struct SkRect; | 18 struct SkRect; |
| 19 class SkSurface; |
17 typedef unsigned long DWORD; | 20 typedef unsigned long DWORD; |
18 typedef DWORD COLORREF; | 21 typedef DWORD COLORREF; |
19 typedef struct tagPOINT POINT; | 22 typedef struct tagPOINT POINT; |
20 typedef struct tagRECT RECT; | 23 typedef struct tagRECT RECT; |
21 | 24 |
22 namespace skia { | 25 namespace skia { |
23 | 26 |
24 // Converts a Skia point to a Windows POINT. | 27 // Converts a Skia point to a Windows POINT. |
25 POINT SkPointToPOINT(const SkPoint& point); | 28 POINT SkPointToPOINT(const SkPoint& point); |
26 | 29 |
(...skipping 26 matching lines...) Expand all Loading... |
53 // Converts scale, skew, and translation to Windows format and sets it on the | 56 // Converts scale, skew, and translation to Windows format and sets it on the |
54 // HDC. | 57 // HDC. |
55 SK_API void LoadTransformToDC(HDC dc, const SkMatrix& matrix); | 58 SK_API void LoadTransformToDC(HDC dc, const SkMatrix& matrix); |
56 | 59 |
57 // Copies |src_rect| from source into destination. | 60 // Copies |src_rect| from source into destination. |
58 // Takes a potentially-slower path if |is_opaque| is false. | 61 // Takes a potentially-slower path if |is_opaque| is false. |
59 // Sets |transform| on source afterwards! | 62 // Sets |transform| on source afterwards! |
60 SK_API void CopyHDC(HDC source, HDC destination, int x, int y, bool is_opaque, | 63 SK_API void CopyHDC(HDC source, HDC destination, int x, int y, bool is_opaque, |
61 const RECT& src_rect, const SkMatrix& transform); | 64 const RECT& src_rect, const SkMatrix& transform); |
62 | 65 |
| 66 // Creates a surface writing to the pixels backing |context|'s bitmap. |
| 67 // Returns null on error. |
| 68 SK_API sk_sp<SkSurface> MapPlatformSurface(HDC context); |
| 69 |
| 70 // Creates a bitmap backed by the same pixels backing the HDC's bitmap. |
| 71 // Returns an empty bitmap on error. |
| 72 SK_API SkBitmap MapPlatformBitmap(HDC context); |
| 73 |
| 74 // Creates an offscreen HDC suitable for writing to via MapPlatformSurface(). |
| 75 // Caller is responsible for calling DeleteDC() when done. |
| 76 // Will return null if any errors are encountered. |
| 77 // TODO(fmalita): consider returning ScopedCreateDC() when that type is |
| 78 // returnable (https://crbug.com/622442) |
| 79 SK_API HDC CreateOffscreenSurface(int width, int height); |
| 80 |
63 // Fills in a BITMAPINFOHEADER structure given the bitmap's size. | 81 // Fills in a BITMAPINFOHEADER structure given the bitmap's size. |
64 SK_API void CreateBitmapHeader(int width, int height, BITMAPINFOHEADER* hdr); | 82 SK_API void CreateBitmapHeader(int width, int height, BITMAPINFOHEADER* hdr); |
65 | 83 |
66 SK_API HBITMAP CreateHBitmap(int width, int height, bool is_opaque, | 84 SK_API HBITMAP CreateHBitmap(int width, int height, bool is_opaque, |
67 HANDLE shared_section = nullptr, | 85 HANDLE shared_section = nullptr, |
68 void** data = nullptr); | 86 void** data = nullptr); |
69 | 87 |
70 } // namespace skia | 88 } // namespace skia |
71 | 89 |
72 #endif // SKIA_EXT_SKIA_UTILS_WIN_H_ | 90 #endif // SKIA_EXT_SKIA_UTILS_WIN_H_ |
73 | 91 |
OLD | NEW |