summaryrefslogtreecommitdiff
path: root/src/video/win32_v.cpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-06-17 10:34:43 +0200
committerPatric Stout <github@truebrain.nl>2021-06-26 20:28:05 +0200
commit74186998a2ab7f45053aa771d179dd8aa24f0d86 (patch)
tree21642633df84c511aa24023f080d455f255874b3 /src/video/win32_v.cpp
parent1ed7afc0a8f40325dca8f4bef0b46e5b8dc06713 (diff)
downloadopenttd-74186998a2ab7f45053aa771d179dd8aa24f0d86.tar.xz
Codechange: use _cur_palette the same in all the drivers
It was a bit of a mixed bag. With this change, gfx.cpp is in control who accesses _cur_palette from the video-drivers.
Diffstat (limited to 'src/video/win32_v.cpp')
-rw-r--r--src/video/win32_v.cpp24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp
index df0917ffa..22b8f3541 100644
--- a/src/video/win32_v.cpp
+++ b/src/video/win32_v.cpp
@@ -42,8 +42,7 @@ bool _window_maximize;
static Dimension _bck_resolution;
DWORD _imm_props;
-/** Local copy of the palette for use in the drawing thread. */
-static Palette _local_palette;
+static Palette _local_palette; ///< Current palette to use for drawing.
bool VideoDriver_Win32Base::ClaimMousePointer()
{
@@ -812,9 +811,7 @@ void VideoDriver_Win32Base::MakeDirty(int left, int top, int width, int height)
void VideoDriver_Win32Base::CheckPaletteAnim()
{
- if (_cur_palette.count_dirty == 0) return;
-
- _local_palette = _cur_palette;
+ if (!CopyPalette(_local_palette)) return;
this->MakeDirty(0, 0, _screen.width, _screen.height);
}
@@ -878,10 +875,7 @@ void VideoDriver_Win32Base::ClientSizeChanged(int w, int h, bool force)
{
/* Allocate backing store of the new size. */
if (this->AllocateBackingStore(w, h, force)) {
- /* Mark all palette colours dirty. */
- _cur_palette.first_dirty = 0;
- _cur_palette.count_dirty = 256;
- _local_palette = _cur_palette;
+ CopyPalette(_local_palette, true);
BlitterFactory::GetCurrentBlitter()->PostResize();
@@ -1078,9 +1072,7 @@ bool VideoDriver_Win32GDI::AfterBlitterChange()
void VideoDriver_Win32GDI::MakePalette()
{
- _cur_palette.first_dirty = 0;
- _cur_palette.count_dirty = 256;
- _local_palette = _cur_palette;
+ CopyPalette(_local_palette, true);
LOGPALETTE *pal = (LOGPALETTE*)alloca(sizeof(LOGPALETTE) + (256 - 1) * sizeof(PALETTEENTRY));
@@ -1135,7 +1127,7 @@ void VideoDriver_Win32GDI::Paint()
HBITMAP old_bmp = (HBITMAP)SelectObject(dc2, this->dib_sect);
HPALETTE old_palette = SelectPalette(dc, this->gdi_palette, FALSE);
- if (_cur_palette.count_dirty != 0) {
+ if (_local_palette.count_dirty != 0) {
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
switch (blitter->UsePaletteAnimation()) {
@@ -1154,7 +1146,7 @@ void VideoDriver_Win32GDI::Paint()
default:
NOT_REACHED();
}
- _cur_palette.count_dirty = 0;
+ _local_palette.count_dirty = 0;
}
BitBlt(dc, 0, 0, this->width, this->height, dc2, 0, 0, SRCCOPY);
@@ -1474,7 +1466,7 @@ void VideoDriver_Win32OpenGL::Paint()
{
PerformanceMeasurer framerate(PFE_VIDEO);
- if (_cur_palette.count_dirty != 0) {
+ if (_local_palette.count_dirty != 0) {
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
/* Always push a changed palette to OpenGL. */
@@ -1483,7 +1475,7 @@ void VideoDriver_Win32OpenGL::Paint()
blitter->PaletteAnimate(_local_palette);
}
- _cur_palette.count_dirty = 0;
+ _local_palette.count_dirty = 0;
}
OpenGLBackend::Get()->Paint();