summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/win
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/win')
-rw-r--r--WebCore/platform/win/BitmapInfo.cpp13
-rw-r--r--WebCore/platform/win/BitmapInfo.h21
-rw-r--r--WebCore/platform/win/PopupMenuWin.cpp2
3 files changed, 20 insertions, 16 deletions
diff --git a/WebCore/platform/win/BitmapInfo.cpp b/WebCore/platform/win/BitmapInfo.cpp
index 514f722..610a27e 100644
--- a/WebCore/platform/win/BitmapInfo.cpp
+++ b/WebCore/platform/win/BitmapInfo.cpp
@@ -33,21 +33,14 @@
namespace WebCore {
-BitmapInfo bitmapInfoForSize(int width, int height, WORD bitCount)
+BitmapInfo bitmapInfoForSize(int width, int height, BitmapInfo::BitCount bitCount)
{
- ASSERT_ARG(bitCount, bitCount == 16 || bitCount == 32);
-
BitmapInfo bitmapInfo;
bitmapInfo.bmiHeader.biWidth = width;
bitmapInfo.bmiHeader.biHeight = height;
bitmapInfo.bmiHeader.biPlanes = 1;
bitmapInfo.bmiHeader.biBitCount = bitCount;
bitmapInfo.bmiHeader.biCompression = BI_RGB;
- bitmapInfo.bmiHeader.biSizeImage = 0;
- bitmapInfo.bmiHeader.biXPelsPerMeter = 0;
- bitmapInfo.bmiHeader.biYPelsPerMeter = 0;
- bitmapInfo.bmiHeader.biClrUsed = 0;
- bitmapInfo.bmiHeader.biClrImportant = 0;
return bitmapInfo;
}
@@ -58,12 +51,12 @@ BitmapInfo::BitmapInfo()
bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
}
-BitmapInfo BitmapInfo::create(const IntSize& size, WORD bitCount)
+BitmapInfo BitmapInfo::create(const IntSize& size, BitCount bitCount)
{
return bitmapInfoForSize(size.width(), size.height(), bitCount);
}
-BitmapInfo BitmapInfo::createBottomUp(const IntSize& size, WORD bitCount)
+BitmapInfo BitmapInfo::createBottomUp(const IntSize& size, BitCount bitCount)
{
return bitmapInfoForSize(size.width(), -size.height(), bitCount);
}
diff --git a/WebCore/platform/win/BitmapInfo.h b/WebCore/platform/win/BitmapInfo.h
index d1c3319..caf1b31 100644
--- a/WebCore/platform/win/BitmapInfo.h
+++ b/WebCore/platform/win/BitmapInfo.h
@@ -35,19 +35,30 @@
namespace WebCore {
struct BitmapInfo : public BITMAPINFO {
+ enum BitCount {
+ BitCount1 = 1,
+ BitCount4 = 4,
+ BitCount8 = 8,
+ BitCount16 = 16,
+ BitCount24 = 24,
+ BitCount32 = 32
+ };
+
BitmapInfo();
- static BitmapInfo create(const IntSize&, WORD bitCount = 32);
- static BitmapInfo createBottomUp(const IntSize&, WORD bitCount = 32);
+ static BitmapInfo create(const IntSize&, BitCount bitCount = BitCount32);
+ static BitmapInfo createBottomUp(const IntSize&, BitCount bitCount = BitCount32);
bool is16bit() const { return bmiHeader.biBitCount == 16; }
bool is32bit() const { return bmiHeader.biBitCount == 32; }
unsigned width() const { return abs(bmiHeader.biWidth); }
unsigned height() const { return abs(bmiHeader.biHeight); }
IntSize size() const { return IntSize(width(), height()); }
- unsigned paddedWidth() const { return is16bit() ? (width() + 1) & ~0x1 : width(); }
+ unsigned bytesPerLine() const { return (width() * bmiHeader.biBitCount + 7) / 8; }
+ unsigned paddedBytesPerLine() const { return (bytesPerLine() + 3) & ~0x3; }
+ unsigned paddedWidth() const { return paddedBytesPerLine() * 8 / bmiHeader.biBitCount; }
unsigned numPixels() const { return paddedWidth() * height(); }
- unsigned paddedBytesPerLine() const { return is16bit() ? paddedWidth() * 2 : width() * 4; }
- unsigned bytesPerLine() const { return width() * bmiHeader.biBitCount / 8; }};
+};
+
} // namespace WebCore
#endif // BitmapInfo_h
diff --git a/WebCore/platform/win/PopupMenuWin.cpp b/WebCore/platform/win/PopupMenuWin.cpp
index aaadc53..6e22024 100644
--- a/WebCore/platform/win/PopupMenuWin.cpp
+++ b/WebCore/platform/win/PopupMenuWin.cpp
@@ -581,7 +581,7 @@ void PopupMenuWin::paint(const IntRect& damageRect, HDC hdc)
}
if (!m_bmp) {
#if OS(WINCE)
- BitmapInfo bitmapInfo = BitmapInfo::createBottomUp(clientRect().size(), 16);
+ BitmapInfo bitmapInfo = BitmapInfo::createBottomUp(clientRect().size(), BitmapInfo::BitCount16);
#else
BitmapInfo bitmapInfo = BitmapInfo::createBottomUp(clientRect().size());
#endif