summaryrefslogtreecommitdiff
path: root/src/video/cocoa
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/cocoa
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/cocoa')
-rw-r--r--src/video/cocoa/cocoa_ogl.mm10
-rw-r--r--src/video/cocoa/cocoa_v.mm36
2 files changed, 23 insertions, 23 deletions
diff --git a/src/video/cocoa/cocoa_ogl.mm b/src/video/cocoa/cocoa_ogl.mm
index af9839a1c..30c299d3d 100644
--- a/src/video/cocoa/cocoa_ogl.mm
+++ b/src/video/cocoa/cocoa_ogl.mm
@@ -37,6 +37,8 @@
#import <OpenGL/OpenGL.h>
#import <OpenGL/gl3.h>
+static Palette _local_palette; ///< Current palette to use for drawing.
+
/**
* Important notice regarding all modifications!!!!!!!
@@ -304,17 +306,15 @@ void VideoDriver_CocoaOpenGL::Paint()
{
PerformanceMeasurer framerate(PFE_VIDEO);
- if (_cur_palette.count_dirty != 0) {
+ if (CopyPalette(_local_palette)) {
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
/* Always push a changed palette to OpenGL. */
CGLSetCurrentContext(this->gl_context);
- OpenGLBackend::Get()->UpdatePalette(_cur_palette.palette, _cur_palette.first_dirty, _cur_palette.count_dirty);
+ OpenGLBackend::Get()->UpdatePalette(_local_palette.palette, _local_palette.first_dirty, _local_palette.count_dirty);
if (blitter->UsePaletteAnimation() == Blitter::PALETTE_ANIMATION_BLITTER) {
- blitter->PaletteAnimate(_cur_palette);
+ blitter->PaletteAnimate(_local_palette);
}
-
- _cur_palette.count_dirty = 0;
}
[ CATransaction begin ];
diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm
index f43ea9b28..2f0f2a746 100644
--- a/src/video/cocoa/cocoa_v.mm
+++ b/src/video/cocoa/cocoa_v.mm
@@ -72,6 +72,7 @@
#endif
bool _cocoa_video_started = false;
+static Palette _local_palette; ///< Current palette to use for drawing.
extern bool _tab_is_down;
@@ -714,9 +715,9 @@ void VideoDriver_CocoaQuartz::UpdatePalette(uint first_color, uint num_colors)
for (uint i = first_color; i < first_color + num_colors; i++) {
uint32 clr = 0xff000000;
- clr |= (uint32)_cur_palette.palette[i].r << 16;
- clr |= (uint32)_cur_palette.palette[i].g << 8;
- clr |= (uint32)_cur_palette.palette[i].b;
+ clr |= (uint32)_local_palette.palette[i].r << 16;
+ clr |= (uint32)_local_palette.palette[i].g << 8;
+ clr |= (uint32)_local_palette.palette[i].b;
this->palette[i] = clr;
}
@@ -725,25 +726,24 @@ void VideoDriver_CocoaQuartz::UpdatePalette(uint first_color, uint num_colors)
void VideoDriver_CocoaQuartz::CheckPaletteAnim()
{
- if (_cur_palette.count_dirty != 0) {
- Blitter *blitter = BlitterFactory::GetCurrentBlitter();
+ if (!CopyPalette(_local_palette)) return;
- switch (blitter->UsePaletteAnimation()) {
- case Blitter::PALETTE_ANIMATION_VIDEO_BACKEND:
- this->UpdatePalette(_cur_palette.first_dirty, _cur_palette.count_dirty);
- break;
+ Blitter *blitter = BlitterFactory::GetCurrentBlitter();
- case Blitter::PALETTE_ANIMATION_BLITTER:
- blitter->PaletteAnimate(_cur_palette);
- break;
+ switch (blitter->UsePaletteAnimation()) {
+ case Blitter::PALETTE_ANIMATION_VIDEO_BACKEND:
+ this->UpdatePalette(_local_palette.first_dirty, _local_palette.count_dirty);
+ break;
- case Blitter::PALETTE_ANIMATION_NONE:
- break;
+ case Blitter::PALETTE_ANIMATION_BLITTER:
+ blitter->PaletteAnimate(_local_palette);
+ break;
- default:
- NOT_REACHED();
- }
- _cur_palette.count_dirty = 0;
+ case Blitter::PALETTE_ANIMATION_NONE:
+ break;
+
+ default:
+ NOT_REACHED();
}
}