From c31ff284c321be86dcd3e4640f11b4e82a6c7cb4 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Mon, 18 Jun 2007 18:45:12 +0000 Subject: [PATCH] (svn r10201) -Codechange: Replace Blitter::SetHorizontalLine with Blitter::DrawRect, as the former was only used by the rectangle drawing code anyway. This lets us draw rectangles in one go. --- src/blitter/32bpp_base.cpp | 15 +++++++++------ src/blitter/32bpp_base.hpp | 2 +- src/blitter/8bpp_base.cpp | 7 +++++-- src/blitter/8bpp_base.hpp | 2 +- src/blitter/base.hpp | 2 +- src/blitter/null.hpp | 2 +- src/gfx.cpp | 5 +---- 7 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/blitter/32bpp_base.cpp b/src/blitter/32bpp_base.cpp index 3f02c08862..6862e29072 100644 --- a/src/blitter/32bpp_base.cpp +++ b/src/blitter/32bpp_base.cpp @@ -18,15 +18,18 @@ void Blitter_32bppBase::SetPixelIfEmpty(void *video, int x, int y, uint8 color) if (*dst == 0) *dst = LookupColourInPalette(color); } -void Blitter_32bppBase::SetHorizontalLine(void *video, int width, uint8 color) +void Blitter_32bppBase::DrawRect(void *video, int width, int height, uint8 color) { - uint32 *dst = (uint32 *)video; uint32 color32 = LookupColourInPalette(color); - for (; width > 0; width--) { - *dst = color32; - dst++; - } + do { + uint32 *dst = (uint32 *)video; + for (int i = width; i > 0; i--) { + *dst = color32; + dst++; + } + video = (uint32 *)video + _screen.pitch; + } while (--height); } void Blitter_32bppBase::CopyFromBuffer(void *video, const void *src, int width, int height, int src_pitch) diff --git a/src/blitter/32bpp_base.hpp b/src/blitter/32bpp_base.hpp index 6ba6ac5346..aaa68ef382 100644 --- a/src/blitter/32bpp_base.hpp +++ b/src/blitter/32bpp_base.hpp @@ -16,7 +16,7 @@ public: /* virtual */ void *MoveTo(const void *video, int x, int y); /* virtual */ void SetPixel(void *video, int x, int y, uint8 color); /* virtual */ void SetPixelIfEmpty(void *video, int x, int y, uint8 color); - /* virtual */ void SetHorizontalLine(void *video, int width, uint8 color); + /* virtual */ void DrawRect(void *video, int width, int height, uint8 color); /* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height, int src_pitch); /* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height, int dst_pitch); /* virtual */ void MoveBuffer(void *video_dst, const void *video_src, int width, int height); diff --git a/src/blitter/8bpp_base.cpp b/src/blitter/8bpp_base.cpp index 48ff3d5474..486d7a1907 100644 --- a/src/blitter/8bpp_base.cpp +++ b/src/blitter/8bpp_base.cpp @@ -28,9 +28,12 @@ void Blitter_8bppBase::SetPixelIfEmpty(void *video, int x, int y, uint8 color) if (*dst == 0) *dst = color; } -void Blitter_8bppBase::SetHorizontalLine(void *video, int width, uint8 color) +void Blitter_8bppBase::DrawRect(void *video, int width, int height, uint8 color) { - memset(video, color, width); + do { + memset(video, color, width); + video = (uint8 *)video + _screen.pitch; + } while (--height); } void Blitter_8bppBase::CopyFromBuffer(void *video, const void *src, int width, int height, int src_pitch) diff --git a/src/blitter/8bpp_base.hpp b/src/blitter/8bpp_base.hpp index 536a6c9842..63b28d2000 100644 --- a/src/blitter/8bpp_base.hpp +++ b/src/blitter/8bpp_base.hpp @@ -16,7 +16,7 @@ public: /* virtual */ void *MoveTo(const void *video, int x, int y); /* virtual */ void SetPixel(void *video, int x, int y, uint8 color); /* virtual */ void SetPixelIfEmpty(void *video, int x, int y, uint8 color); - /* virtual */ void SetHorizontalLine(void *video, int width, uint8 color); + /* virtual */ void DrawRect(void *video, int width, int height, uint8 color); /* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height, int src_pitch); /* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height, int dst_pitch); /* virtual */ void MoveBuffer(void *video_dst, const void *video_src, int width, int height); diff --git a/src/blitter/base.hpp b/src/blitter/base.hpp index abc886a221..79a0895f99 100644 --- a/src/blitter/base.hpp +++ b/src/blitter/base.hpp @@ -94,7 +94,7 @@ public: * @param width The lenght of the line. * @param color A 8bpp mapping color. */ - virtual void SetHorizontalLine(void *video, int width, uint8 color) = 0; + virtual void DrawRect(void *video, int width, int height, uint8 color) = 0; /** * Copy from a buffer to the screen. diff --git a/src/blitter/null.hpp b/src/blitter/null.hpp index 1308559984..b3bbe2212c 100644 --- a/src/blitter/null.hpp +++ b/src/blitter/null.hpp @@ -17,7 +17,7 @@ public: /* virtual */ void *MoveTo(const void *video, int x, int y) { return NULL; }; /* virtual */ void SetPixel(void *video, int x, int y, uint8 color) {}; /* virtual */ void SetPixelIfEmpty(void *video, int x, int y, uint8 color) {}; - /* virtual */ void SetHorizontalLine(void *video, int width, uint8 color) {}; + /* virtual */ void DrawRect(void *video, int width, int height, uint8 color) {}; /* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height, int src_pitch) {}; /* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) {}; /* virtual */ void MoveBuffer(void *video_dst, const void *video_src, int width, int height) {}; diff --git a/src/gfx.cpp b/src/gfx.cpp index d34aae7a02..f5f381e62b 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -148,10 +148,7 @@ void GfxFillRect(int left, int top, int right, int bottom, int color) if (!HASBIT(color, PALETTE_MODIFIER_GREYOUT)) { if (!HASBIT(color, USE_COLORTABLE)) { - do { - blitter->SetHorizontalLine(dst, right, (uint8)color); - dst = blitter->MoveTo(dst, 0, 1); - } while (--bottom); + blitter->DrawRect(dst, right, bottom, (uint8)color); } else { blitter->DrawColorMappingRect(dst, right, bottom, GB(color, 0, PALETTE_WIDTH)); }