Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(566)

Unified Diff: ui/gfx/gdi_util.cc

Issue 1492353002: Consolidate Windows bitmap and DC code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-printing-dc-from-device
Patch Set: fix bad merge Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/gdi_util.h ('k') | ui/gfx/icon_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/gdi_util.cc
diff --git a/ui/gfx/gdi_util.cc b/ui/gfx/gdi_util.cc
index 24000aef13ea4acd5fed7a590bf8de37c60fe0ac..e94f0e49792b030d4f515612484944e598880e0f 100644
--- a/ui/gfx/gdi_util.cc
+++ b/ui/gfx/gdi_util.cc
@@ -10,40 +10,15 @@
#include <memory>
#include "base/logging.h"
-
-namespace {
-
-void CreateBitmapHeaderWithColorDepth(LONG width,
- LONG height,
- WORD color_depth,
- BITMAPINFOHEADER* hdr) {
- // These values are shared with gfx::PlatformDevice
- hdr->biSize = sizeof(BITMAPINFOHEADER);
- hdr->biWidth = width;
- hdr->biHeight = -height; // minus means top-down bitmap
- hdr->biPlanes = 1;
- hdr->biBitCount = color_depth;
- hdr->biCompression = BI_RGB; // no compression
- hdr->biSizeImage = 0;
- hdr->biXPelsPerMeter = 1;
- hdr->biYPelsPerMeter = 1;
- hdr->biClrUsed = 0;
- hdr->biClrImportant = 0;
-}
-
-} // namespace
+#include "skia/ext/skia_utils_win.h"
namespace gfx {
-void CreateBitmapHeader(int width, int height, BITMAPINFOHEADER* hdr) {
- CreateBitmapHeaderWithColorDepth(width, height, 32, hdr);
-}
-
void CreateBitmapV4Header(int width, int height, BITMAPV4HEADER* hdr) {
// Because bmp v4 header is just an extension, we just create a v3 header and
// copy the bits over to the v4 header.
BITMAPINFOHEADER header_v3;
- CreateBitmapHeader(width, height, &header_v3);
+ skia::CreateBitmapHeader(width, height, &header_v3);
memset(hdr, 0, sizeof(BITMAPV4HEADER));
memcpy(hdr, &header_v3, sizeof(BITMAPINFOHEADER));
@@ -55,43 +30,6 @@ void CreateBitmapV4Header(int width, int height, BITMAPV4HEADER* hdr) {
hdr->bV4AlphaMask = 0xff000000;
}
-// Creates a monochrome bitmap header.
-void CreateMonochromeBitmapHeader(int width,
- int height,
- BITMAPINFOHEADER* hdr) {
- CreateBitmapHeaderWithColorDepth(width, height, 1, hdr);
-}
-
-void SubtractRectanglesFromRegion(HRGN hrgn,
- const std::vector<gfx::Rect>& cutouts) {
- if (cutouts.size()) {
- HRGN cutout = ::CreateRectRgn(0, 0, 0, 0);
- for (size_t i = 0; i < cutouts.size(); i++) {
- ::SetRectRgn(cutout,
- cutouts[i].x(),
- cutouts[i].y(),
- cutouts[i].right(),
- cutouts[i].bottom());
- ::CombineRgn(hrgn, hrgn, cutout, RGN_DIFF);
- }
- ::DeleteObject(cutout);
- }
-}
-
-HRGN ConvertPathToHRGN(const gfx::Path& path) {
- int point_count = path.getPoints(NULL, 0);
- std::unique_ptr<SkPoint[]> points(new SkPoint[point_count]);
- path.getPoints(points.get(), point_count);
- std::unique_ptr<POINT[]> windows_points(new POINT[point_count]);
- for (int i = 0; i < point_count; ++i) {
- windows_points[i].x = SkScalarRoundToInt(points[i].fX);
- windows_points[i].y = SkScalarRoundToInt(points[i].fY);
- }
-
- return ::CreatePolygonRgn(windows_points.get(), point_count, ALTERNATE);
-}
-
-
float CalculatePageScale(HDC dc, int page_width, int page_height) {
int dc_width = GetDeviceCaps(dc, HORZRES);
int dc_height = GetDeviceCaps(dc, VERTRES);
« no previous file with comments | « ui/gfx/gdi_util.h ('k') | ui/gfx/icon_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698