summaryrefslogtreecommitdiff
path: root/src/graphics.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-05 02:08:11 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-05 02:09:08 +0300
commitc0ec0ae9ec97f89a7bfc45f9428dac61a5fef45c (patch)
tree308ebfac5f66995116993019d4c51b55defd4d74 /src/graphics.cpp
parentee7c35db55d587136970712158481cd3d94d3db5 (diff)
downloadplus-c0ec0ae9ec97f89a7bfc45f9428dac61a5fef45c.tar.gz
plus-c0ec0ae9ec97f89a7bfc45f9428dac61a5fef45c.tar.bz2
plus-c0ec0ae9ec97f89a7bfc45f9428dac61a5fef45c.tar.xz
plus-c0ec0ae9ec97f89a7bfc45f9428dac61a5fef45c.zip
Another fix for fillrectangle function.
Diffstat (limited to 'src/graphics.cpp')
-rw-r--r--src/graphics.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 6dc3cede8..507f16a6e 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -1325,6 +1325,15 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle)
const unsigned gMask = format->Gmask;
const unsigned bMask = format->Bmask;
const unsigned aMask = format->Amask;
+ unsigned rShift = rMask / 0xff;
+ unsigned gShift = gMask / 0xff;
+ unsigned bShift = bMask / 0xff;
+ if (!rShift)
+ rShift = 1;
+ if (!gShift)
+ gShift = 1;
+ if (!bShift)
+ bShift = 1;
if (pixel != mOldPixel || mColor.a != mOldAlpha)
{
const unsigned pb = (pixel & bMask) * mColor.a;
@@ -1332,9 +1341,9 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle)
const unsigned pr = (pixel & rMask) * mColor.a;
const unsigned a0 = (255 - mColor.a);
- const unsigned int a1 = a0 * bMask / 0xff;
- const unsigned int a2 = a0 * gMask / 0xff;
- const unsigned int a3 = a0 * rMask / 0xff;
+ const unsigned int a1 = a0 * bShift;
+ const unsigned int a2 = a0 * gShift;
+ const unsigned int a3 = a0 * rShift;
for (int f = 0; f <= 0xff; f ++)
{
@@ -1356,8 +1365,9 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle)
{
uint32_t *const p = p0 + x;
const uint32_t dst = *p;
- *p = cB[dst & bMask] | cG[(dst & gMask) >> 8]
- | cR[(dst & 0xff0000) >> 16];
+ *p = cB[dst & bMask / bShift]
+ | cG[(dst & gMask) / gShift]
+ | cR[(dst & rMask) / rShift];
}
}
#endif