mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-23 16:34:06 +00:00
Update mxvideopresenter.cpp (#429)
This commit is contained in:
@@ -20,7 +20,6 @@ MxVideoPresenter::AlphaMask::AlphaMask(const MxBitmap& p_bitmap)
|
|||||||
m_bitmask = new MxU8[size];
|
m_bitmask = new MxU8[size];
|
||||||
memset(m_bitmask, 0, size);
|
memset(m_bitmask, 0, size);
|
||||||
|
|
||||||
MxU32 biCompression = p_bitmap.GetBmiHeader()->biCompression;
|
|
||||||
MxU32 rowsBeforeTop;
|
MxU32 rowsBeforeTop;
|
||||||
MxU8* bitmapSrcPtr;
|
MxU8* bitmapSrcPtr;
|
||||||
|
|
||||||
@@ -32,36 +31,25 @@ MxVideoPresenter::AlphaMask::AlphaMask(const MxBitmap& p_bitmap)
|
|||||||
// Reminder: Negative biHeight means this is a top-down DIB.
|
// Reminder: Negative biHeight means this is a top-down DIB.
|
||||||
// Otherwise it is bottom-up.
|
// Otherwise it is bottom-up.
|
||||||
|
|
||||||
if (biCompression == BI_RGB) {
|
switch (p_bitmap.GetBmiHeader()->biCompression) {
|
||||||
// DECOMP: I think this must be an OR. If not, the check for
|
case BI_RGB: {
|
||||||
// biCompression == 16 gets optimized away.
|
if (p_bitmap.GetBmiHeight() < 0)
|
||||||
if (biCompression == BI_RGB_TOPDOWN || p_bitmap.GetBmiHeight() < 0) {
|
|
||||||
rowsBeforeTop = 0;
|
rowsBeforeTop = 0;
|
||||||
|
else
|
||||||
|
rowsBeforeTop = p_bitmap.GetBmiHeightAbs() - 1;
|
||||||
|
bitmapSrcPtr = p_bitmap.GetBitmapData() + (p_bitmap.GetBmiStride() * rowsBeforeTop);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else {
|
case BI_RGB_TOPDOWN:
|
||||||
rowsBeforeTop = p_bitmap.GetBmiHeightAbs();
|
|
||||||
rowsBeforeTop--;
|
|
||||||
}
|
|
||||||
|
|
||||||
goto seek_to_last_row;
|
|
||||||
}
|
|
||||||
else if (biCompression == BI_RGB_TOPDOWN) {
|
|
||||||
// DECOMP: This is the only condition where we skip the
|
|
||||||
// calculation below.
|
|
||||||
bitmapSrcPtr = p_bitmap.GetBitmapData();
|
bitmapSrcPtr = p_bitmap.GetBitmapData();
|
||||||
}
|
break;
|
||||||
else {
|
default: {
|
||||||
if (p_bitmap.GetBmiHeight() < 0) {
|
if (p_bitmap.GetBmiHeight() < 0)
|
||||||
rowsBeforeTop = 0;
|
rowsBeforeTop = 0;
|
||||||
|
else
|
||||||
|
rowsBeforeTop = p_bitmap.GetBmiHeightAbs() - 1;
|
||||||
|
bitmapSrcPtr = p_bitmap.GetBitmapData() + (p_bitmap.GetBmiStride() * rowsBeforeTop);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
rowsBeforeTop = p_bitmap.GetBmiHeightAbs();
|
|
||||||
rowsBeforeTop--;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: would prefer not to use goto if we can figure this structure out
|
|
||||||
seek_to_last_row:
|
|
||||||
bitmapSrcPtr = p_bitmap.GetBmiStride() * rowsBeforeTop + p_bitmap.GetBitmapData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// How many bytes are there for each row of the bitmap?
|
// How many bytes are there for each row of the bitmap?
|
||||||
@@ -69,15 +57,15 @@ MxVideoPresenter::AlphaMask::AlphaMask(const MxBitmap& p_bitmap)
|
|||||||
// If this is a bottom-up DIB, we will walk it in reverse.
|
// If this is a bottom-up DIB, we will walk it in reverse.
|
||||||
// TODO: Same rounding trick as in MxBitmap
|
// TODO: Same rounding trick as in MxBitmap
|
||||||
MxS32 rowSeek = ((m_width + 3) & -4);
|
MxS32 rowSeek = ((m_width + 3) & -4);
|
||||||
if (p_bitmap.GetBmiHeight() < 0)
|
if (p_bitmap.GetBmiHeader()->biCompression != 16 && p_bitmap.GetBmiHeight() > 0)
|
||||||
rowSeek = -rowSeek;
|
rowSeek = -rowSeek;
|
||||||
|
|
||||||
// The actual offset into the m_bitmask array. The two for-loops
|
// The actual offset into the m_bitmask array. The two for-loops
|
||||||
// are just for counting the pixels.
|
// are just for counting the pixels.
|
||||||
MxS32 offset = 0;
|
MxS32 offset = 0;
|
||||||
|
|
||||||
MxU8* tPtr = bitmapSrcPtr;
|
|
||||||
for (MxS32 j = 0; j < m_height; j++) {
|
for (MxS32 j = 0; j < m_height; j++) {
|
||||||
|
MxU8* tPtr = bitmapSrcPtr;
|
||||||
for (MxS32 i = 0; i < m_width; i++) {
|
for (MxS32 i = 0; i < m_width; i++) {
|
||||||
if (*tPtr) {
|
if (*tPtr) {
|
||||||
// TODO: Second CDQ instruction for abs() should not be there.
|
// TODO: Second CDQ instruction for abs() should not be there.
|
||||||
|
Reference in New Issue
Block a user