From 74186998a2ab7f45053aa771d179dd8aa24f0d86 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Thu, 17 Jun 2021 10:34:43 +0200 Subject: 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. --- src/video/cocoa/cocoa_ogl.mm | 10 +++++----- src/video/cocoa/cocoa_v.mm | 36 ++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 23 deletions(-) (limited to 'src/video/cocoa') 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 #import +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(); } } -- cgit v1.2.3-70-g09d2