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 #include "ui/gfx/gdi_util.h" | 5 #include "ui/gfx/gdi_util.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> |
10 | 11 |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 void CreateBitmapHeaderWithColorDepth(LONG width, | 16 void CreateBitmapHeaderWithColorDepth(LONG width, |
17 LONG height, | 17 LONG height, |
18 WORD color_depth, | 18 WORD color_depth, |
19 BITMAPINFOHEADER* hdr) { | 19 BITMAPINFOHEADER* hdr) { |
20 // These values are shared with gfx::PlatformDevice | 20 // These values are shared with gfx::PlatformDevice |
21 hdr->biSize = sizeof(BITMAPINFOHEADER); | 21 hdr->biSize = sizeof(BITMAPINFOHEADER); |
22 hdr->biWidth = width; | 22 hdr->biWidth = width; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 cutouts[i].right(), | 73 cutouts[i].right(), |
74 cutouts[i].bottom()); | 74 cutouts[i].bottom()); |
75 ::CombineRgn(hrgn, hrgn, cutout, RGN_DIFF); | 75 ::CombineRgn(hrgn, hrgn, cutout, RGN_DIFF); |
76 } | 76 } |
77 ::DeleteObject(cutout); | 77 ::DeleteObject(cutout); |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 HRGN ConvertPathToHRGN(const gfx::Path& path) { | 81 HRGN ConvertPathToHRGN(const gfx::Path& path) { |
82 int point_count = path.getPoints(NULL, 0); | 82 int point_count = path.getPoints(NULL, 0); |
83 scoped_ptr<SkPoint[]> points(new SkPoint[point_count]); | 83 std::unique_ptr<SkPoint[]> points(new SkPoint[point_count]); |
84 path.getPoints(points.get(), point_count); | 84 path.getPoints(points.get(), point_count); |
85 scoped_ptr<POINT[]> windows_points(new POINT[point_count]); | 85 std::unique_ptr<POINT[]> windows_points(new POINT[point_count]); |
86 for (int i = 0; i < point_count; ++i) { | 86 for (int i = 0; i < point_count; ++i) { |
87 windows_points[i].x = SkScalarRoundToInt(points[i].fX); | 87 windows_points[i].x = SkScalarRoundToInt(points[i].fX); |
88 windows_points[i].y = SkScalarRoundToInt(points[i].fY); | 88 windows_points[i].y = SkScalarRoundToInt(points[i].fY); |
89 } | 89 } |
90 | 90 |
91 return ::CreatePolygonRgn(windows_points.get(), point_count, ALTERNATE); | 91 return ::CreatePolygonRgn(windows_points.get(), point_count, ALTERNATE); |
92 } | 92 } |
93 | 93 |
94 | 94 |
95 float CalculatePageScale(HDC dc, int page_width, int page_height) { | 95 float CalculatePageScale(HDC dc, int page_width, int page_height) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } else { | 132 } else { |
133 rv = ::StretchDIBits(hdc, | 133 rv = ::StretchDIBits(hdc, |
134 dest_x, dest_y, dest_w, dest_h, | 134 dest_x, dest_y, dest_w, dest_h, |
135 src_x, bottom_up_src_y, src_w, src_h, | 135 src_x, bottom_up_src_y, src_w, src_h, |
136 pixels, bitmap_info, DIB_RGB_COLORS, SRCCOPY); | 136 pixels, bitmap_info, DIB_RGB_COLORS, SRCCOPY); |
137 } | 137 } |
138 DCHECK(rv != static_cast<int>(GDI_ERROR)); | 138 DCHECK(rv != static_cast<int>(GDI_ERROR)); |
139 } | 139 } |
140 | 140 |
141 } // namespace gfx | 141 } // namespace gfx |
OLD | NEW |