diff options
author | truelight <truelight@openttd.org> | 2007-06-19 15:04:08 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2007-06-19 15:04:08 +0000 |
commit | 1c4760ee06fb632d27648175f7bab433b32c1892 (patch) | |
tree | aacf68dc44607bc64afffcb18f3bcbf65d05d654 /src/video | |
parent | 9ad02c11c62bec4027f36fadbab9d81180dc2721 (diff) | |
download | openttd-1c4760ee06fb632d27648175f7bab433b32c1892.tar.xz |
(svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
-Codechange: allow blitters to handle palette animation internally or even disable it; 8bpp uses video-backend for palette animation
Diffstat (limited to 'src/video')
-rw-r--r-- | src/video/cocoa_v.mm | 20 | ||||
-rw-r--r-- | src/video/sdl_v.cpp | 26 | ||||
-rw-r--r-- | src/video/win32_v.cpp | 22 |
3 files changed, 54 insertions, 14 deletions
diff --git a/src/video/cocoa_v.mm b/src/video/cocoa_v.mm index 3af09da18..eb0b5919b 100644 --- a/src/video/cocoa_v.mm +++ b/src/video/cocoa_v.mm @@ -205,9 +205,23 @@ static uint32 GetTick() static void QZ_CheckPaletteAnim() { - if (_pal_last_dirty != -1) { - QZ_UpdatePalette(_pal_first_dirty, _pal_last_dirty - _pal_first_dirty + 1); - _pal_last_dirty = -1; + if (_pal_count_dirty != 0) { + switch (blitter->UsePaletteAnimation()) { + case Blitter::PALETTE_ANIMATION_VIDEO_BACKEND: + QZ_UpdatePalette(_pal_first_dirty, _pal_count_dirty); + break; + + case Blitter::PALETTE_ANIMATION_BLITTER: + blitter->PaletteAnimate(_pal_first_dirty, _pal_count_dirty); + break; + + case Blitter::PALETTE_ANIMATION_NONE: + break; + + default: + NOT_REACHED(); + } + _pal_count_dirty = 0; } } diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index 3a1f2229e..087a3464c 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -37,10 +37,6 @@ static void SdlVideoMakeDirty(int left, int top, int width, int height) static void UpdatePalette(uint start, uint count) { - /* We can only update the palette in 8bpp for now */ - /* TODO -- We need support for other bpps too! */ - if (BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() != 8) return; - SDL_Color pal[256]; uint i; @@ -61,9 +57,25 @@ static void InitPalette() static void CheckPaletteAnim() { - if (_pal_last_dirty != -1) { - UpdatePalette(_pal_first_dirty, _pal_last_dirty - _pal_first_dirty + 1); - _pal_last_dirty = -1; + Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); + + if (_pal_count_dirty != 0) { + switch (blitter->UsePaletteAnimation()) { + case Blitter::PALETTE_ANIMATION_VIDEO_BACKEND: + UpdatePalette(_pal_first_dirty, _pal_count_dirty); + break; + + case Blitter::PALETTE_ANIMATION_BLITTER: + blitter->PaletteAnimate(_pal_first_dirty, _pal_count_dirty); + break; + + case Blitter::PALETTE_ANIMATION_NONE: + break; + + default: + NOT_REACHED(); + } + _pal_count_dirty = 0; } } diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index b67674627..79517843f 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -145,7 +145,7 @@ static void ClientSizeChanged(int w, int h) if (AllocateDibSection(w, h)) { // mark all palette colors dirty _pal_first_dirty = 0; - _pal_last_dirty = 255; + _pal_count_dirty = 255; GameSizeChanged(); // redraw screen @@ -231,9 +231,23 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP old_bmp = (HBITMAP)SelectObject(dc2, _wnd.dib_sect); old_palette = SelectPalette(dc, _wnd.gdi_palette, FALSE); - if (_pal_last_dirty != -1) { - UpdatePalette(dc2, _pal_first_dirty, _pal_last_dirty - _pal_first_dirty + 1); - _pal_last_dirty = -1; + if (_pal_count_dirty != 0) { + switch (blitter->UsePaletteAnimation()) { + case Blitter::PALETTE_ANIMATION_VIDEO_BACKEND: + UpdatePalette(_pal_first_dirty, _pal_count_dirty); + break; + + case Blitter::PALETTE_ANIMATION_BLITTER: + blitter->PaletteAnimate(_pal_first_dirty, _pal_count_dirty); + break; + + case Blitter::PALETTE_ANIMATION_NONE: + break; + + default: + NOT_REACHED(); + } + _pal_count_dirty = 0; } BitBlt(dc, 0, 0, _wnd.width, _wnd.height, dc2, 0, 0, SRCCOPY); |