Changeset - r14230:acffc5584059
[Not reviewed]
master
0 1 0
rubidium - 15 years ago 2010-01-12 16:38:48
rubidium@openttd.org
(svn r18791) -Fix [FS#3504]: when copying an 'image' back into the buffer the 32bpp anim blitter triggered palette check of the whole window instead of only the part the got copied back
1 file changed with 23 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/blitter/32bpp_anim.cpp
Show inline comments
 
@@ -308,11 +308,15 @@ void Blitter_32bppAnim::CopyFromBuffer(v
 
	assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
 
	uint32 *dst = (uint32 *)video;
 
	uint32 *usrc = (uint32 *)src;
 
	uint8 *anim_line;
 
	uint8 *anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
 

	
 
	anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
 
	int count = (_use_palette == PAL_DOS) ? PALETTE_ANIM_SIZE_DOS : PALETTE_ANIM_SIZE_WIN;
 

	
 
	for (; height > 0; height--) {
 
		/* We need to keep those for palette animation. */
 
		uint32 *dst_pal = dst;
 
		uint8 *anim_pal = anim_line;
 

	
 
		memcpy(dst, usrc, width * sizeof(uint32));
 
		usrc += width;
 
		dst += _screen.pitch;
 
@@ -320,10 +324,24 @@ void Blitter_32bppAnim::CopyFromBuffer(v
 
		memcpy(anim_line, usrc, width * sizeof(uint8));
 
		usrc = (uint32 *)((uint8 *)usrc + width);
 
		anim_line += this->anim_buf_width;
 

	
 
		/* Okay, it is *very* likely that the image we stored is using
 
		 * the wrong palette animated colours. There are two things we
 
		 * can do to fix this. The first is simply reviewing the whole
 
		 * screen after we copied the buffer, i.e. run PaletteAnimate,
 
		 * however that forces a full screen redraw which is expensive
 
		 * for just the cursor. This just copies the implementation of
 
		 * palette animation, much cheaper though slightly nastier. */
 
		for (int i = 0; i < width; i++) {
 
			uint colour = *anim_pal;
 
			if (IsInsideBS(colour, PALETTE_ANIM_SIZE_START, count)) {
 
				/* Update this pixel */
 
				*dst_pal = LookupColourInPalette(colour);
 
			}
 
			dst_pal++;
 
			anim_pal++;
 
		}
 
	}
 

	
 
	/* We update the palette (or the pixels that do animation) immediatly, to avoid graphical glitches */
 
	this->PaletteAnimate(PALETTE_ANIM_SIZE_START, (_use_palette == PAL_DOS) ? PALETTE_ANIM_SIZE_DOS : PALETTE_ANIM_SIZE_WIN);
 
}
 

	
 
void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height)
0 comments (0 inline, 0 general)