summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-01-11 17:12:41 +0000
committerfrosch <frosch@openttd.org>2008-01-11 17:12:41 +0000
commitcbe7e5d668196975bee9d1a288dec5eff07c768f (patch)
tree1c8f4f25209426578fbcfb87aa8be78f439db8c0 /src
parent4d040771560af57e4bdc32e3e5de77f8c74022df (diff)
downloadopenttd-cbe7e5d668196975bee9d1a288dec5eff07c768f.tar.xz
(svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
Diffstat (limited to 'src')
-rw-r--r--src/blitter/32bpp_anim.cpp26
-rw-r--r--src/gfx.cpp1
-rw-r--r--src/gfx_func.h1
-rw-r--r--src/screenshot.cpp23
4 files changed, 47 insertions, 4 deletions
diff --git a/src/blitter/32bpp_anim.cpp b/src/blitter/32bpp_anim.cpp
index 40bf358db..6af9926e1 100644
--- a/src/blitter/32bpp_anim.cpp
+++ b/src/blitter/32bpp_anim.cpp
@@ -13,7 +13,7 @@ static FBlitter_32bppAnim iFBlitter_32bppAnim;
void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
{
- if (bp->dst < _screen.dst_ptr || bp->dst > (uint32 *)_screen.dst_ptr + _screen.width * _screen.height) {
+ if (_screen_disable_anim) {
/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent Draw() */
Blitter_32bppOptimized::Draw(bp, mode, zoom);
return;
@@ -98,6 +98,12 @@ void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL
void Blitter_32bppAnim::DrawColorMappingRect(void *dst, int width, int height, int pal)
{
+ if (_screen_disable_anim) {
+ /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawColorMappingRect() */
+ Blitter_32bppOptimized::DrawColorMappingRect(dst, width, height, pal);
+ return;
+ }
+
uint32 *udst = (uint32 *)dst;
uint8 *anim;
@@ -136,7 +142,9 @@ void Blitter_32bppAnim::DrawColorMappingRect(void *dst, int width, int height, i
void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8 color)
{
*((uint32 *)video + x + y * _screen.pitch) = LookupColourInPalette(color);
- /* Set the color in the anim-buffer too */
+
+ /* Set the color in the anim-buffer too, if we are rendering to the screen */
+ if (_screen_disable_anim) return;
this->anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->anim_buf_width] = color;
}
@@ -145,13 +153,20 @@ void Blitter_32bppAnim::SetPixelIfEmpty(void *video, int x, int y, uint8 color)
uint32 *dst = (uint32 *)video + x + y * _screen.pitch;
if (*dst == 0) {
*dst = LookupColourInPalette(color);
- /* Set the color in the anim-buffer too */
+ /* Set the color in the anim-buffer too, if we are rendering to the screen */
+ if (_screen_disable_anim) return;
this->anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->anim_buf_width] = color;
}
}
void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 color)
{
+ if (_screen_disable_anim) {
+ /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */
+ Blitter_32bppOptimized::DrawRect(video, width, height, color);
+ return;
+ }
+
uint32 color32 = LookupColourInPalette(color);
uint8 *anim_line;
@@ -175,6 +190,7 @@ void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 color
void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width, int height)
{
+ assert(!_screen_disable_anim);
assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint32 *dst = (uint32 *)video;
uint32 *usrc = (uint32 *)src;
@@ -198,6 +214,7 @@ void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width,
void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height)
{
+ assert(!_screen_disable_anim);
assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint32 *udst = (uint32 *)dst;
uint32 *src = (uint32 *)video;
@@ -220,6 +237,8 @@ void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, in
void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
{
+ assert(!_screen_disable_anim);
+ assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint8 *dst, *src;
/* We need to scroll the anim-buffer too */
@@ -268,6 +287,7 @@ int Blitter_32bppAnim::BufferSize(int width, int height)
void Blitter_32bppAnim::PaletteAnimate(uint start, uint count)
{
+ assert(!_screen_disable_anim);
uint8 *anim = this->anim_buf;
/* Never repaint the transparency pixel */
diff --git a/src/gfx.cpp b/src/gfx.cpp
index 322c450dd..8f2717e1f 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -31,6 +31,7 @@ bool _left_button_clicked;
bool _right_button_down;
bool _right_button_clicked;
DrawPixelInfo _screen;
+bool _screen_disable_anim = false; ///< Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
bool _exit_game;
bool _networking; ///< are we in networking mode?
byte _game_mode;
diff --git a/src/gfx_func.h b/src/gfx_func.h
index 0103e7044..a4033caed 100644
--- a/src/gfx_func.h
+++ b/src/gfx_func.h
@@ -55,6 +55,7 @@ extern bool _right_button_down;
extern bool _right_button_clicked;
extern DrawPixelInfo _screen;
+extern bool _screen_disable_anim; ///< Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
extern int _pal_first_dirty;
extern int _pal_count_dirty;
diff --git a/src/screenshot.cpp b/src/screenshot.cpp
index c20512d6c..822a3e0cf 100644
--- a/src/screenshot.cpp
+++ b/src/screenshot.cpp
@@ -488,13 +488,29 @@ static void CurrentScreenCallback(void *userdata, void *buf, uint y, uint pitch,
blitter->CopyImageToBuffer(src, buf, _screen.width, n, pitch);
}
-/* generate a large piece of the world */
+/** generate a large piece of the world
+ * @param userdata Viewport area to draw
+ * @param buf Videobuffer with same bitdepth as current blitter
+ * @param y First line to render
+ * @param pitch Pitch of the videobuffer
+ * @param n Number of lines to render
+ */
static void LargeWorldCallback(void *userdata, void *buf, uint y, uint pitch, uint n)
{
ViewPort *vp = (ViewPort *)userdata;
DrawPixelInfo dpi, *old_dpi;
int wx, left;
+ /* We are no longer rendering to the screen */
+ DrawPixelInfo old_screen = _screen;
+ bool old_disable_anim = _screen_disable_anim;
+
+ _screen.dst_ptr = buf;
+ _screen.width = pitch;
+ _screen.height = n;
+ _screen.pitch = pitch;
+ _screen_disable_anim = true;
+
old_dpi = _cur_dpi;
_cur_dpi = &dpi;
@@ -506,6 +522,7 @@ static void LargeWorldCallback(void *userdata, void *buf, uint y, uint pitch, ui
dpi.left = 0;
dpi.top = y;
+ /* Render viewport in blocks of 1600 pixels width */
left = 0;
while (vp->width - left != 0) {
wx = min(vp->width - left, 1600);
@@ -520,6 +537,10 @@ static void LargeWorldCallback(void *userdata, void *buf, uint y, uint pitch, ui
}
_cur_dpi = old_dpi;
+
+ /* Switch back to rendering to the screen */
+ _screen = old_screen;
+ _screen_disable_anim = old_disable_anim;
}
static char *MakeScreenshotName(const char *ext)