Misc. cleanup, primarily removing unused locals.
Also various other fixes, e.g. condensing code, converting DCHECK_LT(0, a) -> DCHECK_GT(a, 0) (and the like) for readability, inserting a few typecasts.
BUG=none
TEST=none
Review URL: https://codereview.chromium.org/637023002
Cr-Commit-Position: refs/heads/master@{#299362}
diff --git a/ui/gfx/gdi_util.cc b/ui/gfx/gdi_util.cc
index 3030a533..996d01e 100644
--- a/ui/gfx/gdi_util.cc
+++ b/ui/gfx/gdi_util.cc
@@ -7,13 +7,11 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
-namespace gfx {
+namespace {
-void CreateBitmapHeader(int width, int height, BITMAPINFOHEADER* hdr) {
- CreateBitmapHeaderWithColorDepth(width, height, 32, hdr);
-}
-
-void CreateBitmapHeaderWithColorDepth(int width, int height, int color_depth,
+void CreateBitmapHeaderWithColorDepth(LONG width,
+ LONG height,
+ WORD color_depth,
BITMAPINFOHEADER* hdr) {
// These values are shared with gfx::PlatformDevice
hdr->biSize = sizeof(BITMAPINFOHEADER);
@@ -29,6 +27,14 @@
hdr->biClrImportant = 0;
}
+} // namespace
+
+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.
@@ -49,17 +55,7 @@
void CreateMonochromeBitmapHeader(int width,
int height,
BITMAPINFOHEADER* hdr) {
- hdr->biSize = sizeof(BITMAPINFOHEADER);
- hdr->biWidth = width;
- hdr->biHeight = -height;
- hdr->biPlanes = 1;
- hdr->biBitCount = 1;
- hdr->biCompression = BI_RGB;
- hdr->biSizeImage = 0;
- hdr->biXPelsPerMeter = 1;
- hdr->biYPelsPerMeter = 1;
- hdr->biClrUsed = 0;
- hdr->biClrImportant = 0;
+ CreateBitmapHeaderWithColorDepth(width, height, 1, hdr);
}
void SubtractRectanglesFromRegion(HRGN hrgn,
diff --git a/ui/gfx/gdi_util.h b/ui/gfx/gdi_util.h
index 03ae91b..f1c0f50 100644
--- a/ui/gfx/gdi_util.h
+++ b/ui/gfx/gdi_util.h
@@ -18,11 +18,6 @@
GFX_EXPORT void CreateBitmapHeader(int width, int height,
BITMAPINFOHEADER* hdr);
-// Creates a BITMAPINFOHEADER structure given the bitmap's size and
-// color depth in bits per pixel.
-void CreateBitmapHeaderWithColorDepth(int width, int height, int color_depth,
- BITMAPINFOHEADER* hdr);
-
// Creates a BITMAPV4HEADER structure given the bitmap's size. You probably
// only need to use BMP V4 if you need transparency (alpha channel). This
// function sets the AlphaMask to 0xff000000.
diff --git a/ui/gfx/win/hwnd_util.cc b/ui/gfx/win/hwnd_util.cc
index 050aa9b..41eead4 100644
--- a/ui/gfx/win/hwnd_util.cc
+++ b/ui/gfx/win/hwnd_util.cc
@@ -112,7 +112,7 @@
void* GetWindowUserData(HWND hwnd) {
DWORD process_id = 0;
- DWORD thread_id = GetWindowThreadProcessId(hwnd, &process_id);
+ GetWindowThreadProcessId(hwnd, &process_id);
// A window outside the current process needs to be ignored.
if (process_id != ::GetCurrentProcessId())
return NULL;