summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-07-04 23:43:12 +0300
committerAndrei Karas <akaras@inbox.ru>2011-07-04 23:43:12 +0300
commit0202b0b4cdac57a04a3765f6bca893bd3b5c9812 (patch)
tree1d91b33250e8f23dcba6e8f8a3d05f94f4e6f070
parent7364862b5947dcc51cd8209199028b135f1b86b0 (diff)
downloadManaVerse-0202b0b4cdac57a04a3765f6bca893bd3b5c9812.tar.gz
ManaVerse-0202b0b4cdac57a04a3765f6bca893bd3b5c9812.tar.bz2
ManaVerse-0202b0b4cdac57a04a3765f6bca893bd3b5c9812.tar.xz
ManaVerse-0202b0b4cdac57a04a3765f6bca893bd3b5c9812.zip
Improve fillRectangle speed in SDL mode.
-rw-r--r--src/graphics.cpp50
1 files changed, 20 insertions, 30 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index ff8bda066..ee848a673 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -737,25 +737,19 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle)
case 1:
for (y = y1; y < y2; y++)
{
+ Uint8 *p = (Uint8 *)mTarget->pixels + y * mTarget->pitch;
for (x = x1; x < x2; x++)
- {
- Uint8 *p = (Uint8 *)mTarget->pixels
- + y * mTarget->pitch + x * bpp;
- *p = pixel;
- //SDLputPixelAlpha(mTarget, x, y, mColor);
- }
+ *(p + x) = pixel;
}
break;
case 2:
for (y = y1; y < y2; y++)
{
+ Uint8 *p = (Uint8 *)mTarget->pixels + y * mTarget->pitch;
for (x = x1; x < x2; x++)
{
- Uint8 *p = (Uint8 *)mTarget->pixels
- + y * mTarget->pitch + x * bpp;
- *(Uint16 *)p = gcn::SDLAlpha16(pixel, *(Uint32 *)p,
- mColor.a, mTarget->format);
- //SDLputPixelAlpha(mTarget, x, y, mColor);
+ *(Uint16 *)(p + x * 2) = gcn::SDLAlpha16(
+ pixel, *(Uint32 *)p, mColor.a, mTarget->format);
}
}
break;
@@ -768,23 +762,19 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle)
for (y = y1; y < y2; y++)
{
+ Uint8 *p0 = (Uint8 *)mTarget->pixels + y * mTarget->pitch;
for (x = x1; x < x2; x++)
{
- Uint8 *p = (Uint8 *)mTarget->pixels
- + y * mTarget->pitch + x * bpp;
- if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
- {
- p[2] = (p[2] * ca + cb) >> 8;
- p[1] = (p[1] * ca + cg) >> 8;
- p[0] = (p[0] * ca + cr) >> 8;
- }
- else
- {
- p[0] = (p[0] * ca + cb) >> 8;
- p[1] = (p[1] * ca + cg) >> 8;
- p[2] = (p[2] * ca + cr) >> 8;
- }
- //SDLputPixelAlpha(mTarget, x, y, mColor);
+ Uint8 *p = p0 + x * 3;
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ p[2] = (p[2] * ca + cb) >> 8;
+ p[1] = (p[1] * ca + cg) >> 8;
+ p[0] = (p[0] * ca + cr) >> 8;
+#else
+ p[0] = (p[0] * ca + cb) >> 8;
+ p[1] = (p[1] * ca + cg) >> 8;
+ p[2] = (p[2] * ca + cr) >> 8;
+#endif
}
}
break;
@@ -797,18 +787,18 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle)
const unsigned a1 = (255 - mColor.a);
for (y = y1; y < y2; y++)
{
+ Uint8 *p0 = (Uint8 *)mTarget->pixels + y * mTarget->pitch;
for (x = x1; x < x2; x++)
{
- Uint8 *p = (Uint8 *)mTarget->pixels
- + y * mTarget->pitch + x * bpp;
+ Uint8 *p = p0 + x * 4;
Uint32 dst = *(Uint32 *)p;
const unsigned int b = (pb + (dst & 0xff) * a1) >> 8;
const unsigned int g = (pg + (dst & 0xff00) * a1) >> 8;
const unsigned int r = (pr
+ (dst & 0xff0000) * a1) >> 8;
- *(Uint32 *)p = ((b & 0xff)
- | (g & 0xff00) | (r & 0xff0000));
+ *(Uint32 *)p = ((b & 0xff) | (g & 0xff00)
+ | (r & 0xff0000));
}
}
break;