From 4e68e4c053623964faf2c16c99f0e886fd2083bb Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 27 Feb 2021 22:40:36 +0200 Subject: [PATCH 6/6] sdl2: Fix alpha channel changes when recentering map Do not use surface blending mode when moving mapview around. Reported by, and initial patch provided by, goduck777 See osdn #41629 Signed-off-by: Marko Lindqvist --- client/gui-gtk-2.0/canvas.c | 9 ++++++++- client/gui-gtk-3.0/canvas.c | 9 ++++++++- client/gui-gtk-3.22/canvas.c | 7 +++++++ client/gui-qt/canvas.cpp | 7 +++++++ client/gui-qt/qtg_cxxside.cpp | 1 + client/gui-qt/qtg_cxxside.h | 1 + client/gui-sdl/canvas.c | 9 ++++++++- client/gui-sdl2/canvas.c | 8 ++++++++ client/gui-stub/canvas.c | 9 ++++++++- client/gui-xaw/mapview.c | 7 +++++++ client/gui_cbsetter.c | 1 + client/gui_interface.c | 8 ++++++++ client/gui_interface.h | 1 + client/include/canvas_g.h | 4 +++- client/mapview_common.c | 2 ++ 15 files changed, 78 insertions(+), 5 deletions(-) diff --git a/client/gui-gtk-2.0/canvas.c b/client/gui-gtk-2.0/canvas.c index fe1bc679a2..f96a16e1df 100644 --- a/client/gui-gtk-2.0/canvas.c +++ b/client/gui-gtk-2.0/canvas.c @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 1996-2005 - Freeciv Development Team This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -60,6 +60,13 @@ bool has_zoom_support(void) return FALSE; } +/**************************************************************************** + Initialize canvas as mapview. +****************************************************************************/ +void canvas_mapview_init(struct canvas *store) +{ +} + /**************************************************************************** Copies an area from the source canvas to the destination canvas. ****************************************************************************/ diff --git a/client/gui-gtk-3.0/canvas.c b/client/gui-gtk-3.0/canvas.c index ec4d44d7cc..4329795445 100644 --- a/client/gui-gtk-3.0/canvas.c +++ b/client/gui-gtk-3.0/canvas.c @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 1996-2005 - Freeciv Development Team This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -63,6 +63,13 @@ bool has_zoom_support(void) return TRUE; } +/**************************************************************************** + Initialize canvas as mapview. +****************************************************************************/ +void canvas_mapview_init(struct canvas *store) +{ +} + /**************************************************************************** Copies an area from the source canvas to the destination canvas. ****************************************************************************/ diff --git a/client/gui-gtk-3.22/canvas.c b/client/gui-gtk-3.22/canvas.c index 0e0a622d7b..fd55cad27d 100644 --- a/client/gui-gtk-3.22/canvas.c +++ b/client/gui-gtk-3.22/canvas.c @@ -63,6 +63,13 @@ bool has_zoom_support(void) return TRUE; } +/**************************************************************************** + Initialize canvas as mapview. +****************************************************************************/ +void canvas_mapview_init(struct canvas *store) +{ +} + /**************************************************************************** Copies an area from the source canvas to the destination canvas. ****************************************************************************/ diff --git a/client/gui-qt/canvas.cpp b/client/gui-qt/canvas.cpp index 8abaa87a83..a16c04d3ff 100644 --- a/client/gui-qt/canvas.cpp +++ b/client/gui-qt/canvas.cpp @@ -65,6 +65,13 @@ bool qtg_has_zoom_support() return FALSE; } +/**************************************************************************** + Initialize canvas as mapview. +****************************************************************************/ +void qtg_canvas_mapview_init(struct canvas *store) +{ +} + /**************************************************************************** Copies an area from the source canvas to the destination canvas. ****************************************************************************/ diff --git a/client/gui-qt/qtg_cxxside.cpp b/client/gui-qt/qtg_cxxside.cpp index f8e3f6acbf..0f63bdf534 100644 --- a/client/gui-qt/qtg_cxxside.cpp +++ b/client/gui-qt/qtg_cxxside.cpp @@ -55,6 +55,7 @@ void setup_gui_funcs() funcs->canvas_free = qtg_canvas_free; funcs->canvas_set_zoom = qtg_canvas_set_zoom; funcs->has_zoom_support = qtg_has_zoom_support; + funcs->canvas_mapview_init = qtg_canvas_mapview_init; funcs->canvas_copy = qtg_canvas_copy; funcs->canvas_put_sprite = qtg_canvas_put_sprite; funcs->canvas_put_sprite_full = qtg_canvas_put_sprite_full; diff --git a/client/gui-qt/qtg_cxxside.h b/client/gui-qt/qtg_cxxside.h index 3dd2433d6d..cf871b7d02 100644 --- a/client/gui-qt/qtg_cxxside.h +++ b/client/gui-qt/qtg_cxxside.h @@ -59,6 +59,7 @@ struct canvas *qtg_canvas_create(int width, int height); void qtg_canvas_free(struct canvas *store); void qtg_canvas_set_zoom(struct canvas *store, float zoom); bool qtg_has_zoom_support(); +void qtg_canvas_mapview_init(struct canvas *store); void qtg_canvas_copy(struct canvas *dest, struct canvas *src, int src_x, int src_y, int dest_x, int dest_y, int width, int height); diff --git a/client/gui-sdl/canvas.c b/client/gui-sdl/canvas.c index 34d40558d0..a36e93aa23 100644 --- a/client/gui-sdl/canvas.c +++ b/client/gui-sdl/canvas.c @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 2005 The Freeciv Team This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -88,6 +88,13 @@ bool has_zoom_support(void) return FALSE; } +/**************************************************************************** + Initialize canvas as mapview. +****************************************************************************/ +void canvas_mapview_init(struct canvas *store) +{ +} + /************************************************************************** Copies an area from the source canvas to the destination canvas. **************************************************************************/ diff --git a/client/gui-sdl2/canvas.c b/client/gui-sdl2/canvas.c index 449fc64bb2..2ca711dc30 100644 --- a/client/gui-sdl2/canvas.c +++ b/client/gui-sdl2/canvas.c @@ -81,6 +81,14 @@ bool has_zoom_support(void) return FALSE; } +/************************************************************************** + Initialize canvas as mapview. +**************************************************************************/ +void canvas_mapview_init(struct canvas *store) +{ + SDL_SetSurfaceBlendMode(store->surf, SDL_BLENDMODE_NONE); +} + /************************************************************************** Copies an area from the source canvas to the destination canvas. **************************************************************************/ diff --git a/client/gui-stub/canvas.c b/client/gui-stub/canvas.c index 14f76fbb10..d3ff77f094 100644 --- a/client/gui-stub/canvas.c +++ b/client/gui-stub/canvas.c @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 1996-2005 - Freeciv Development Team This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -54,6 +54,13 @@ bool gui_has_zoom_support(void) return FALSE; } +/**************************************************************************** + Initialize canvas as mapview. +****************************************************************************/ +void gui_canvas_mapview_init(struct canvas *store) +{ +} + /**************************************************************************** Copies an area from the source canvas to the destination canvas. ****************************************************************************/ diff --git a/client/gui-xaw/mapview.c b/client/gui-xaw/mapview.c index 51493bf82f..371dc61978 100644 --- a/client/gui-xaw/mapview.c +++ b/client/gui-xaw/mapview.c @@ -134,6 +134,13 @@ bool has_zoom_support(void) return FALSE; } +/**************************************************************************** + Initialize canvas as mapview. +****************************************************************************/ +void canvas_mapview_init(struct canvas *store) +{ +} + /**************************************************************************** Return a canvas that is the overview window. ****************************************************************************/ diff --git a/client/gui_cbsetter.c b/client/gui_cbsetter.c index cffe22f975..51af266973 100644 --- a/client/gui_cbsetter.c +++ b/client/gui_cbsetter.c @@ -67,6 +67,7 @@ void setup_gui_funcs(void) funcs->canvas_free = gui_canvas_free; funcs->canvas_set_zoom = gui_canvas_set_zoom; funcs->has_zoom_support = gui_has_zoom_support; + funcs->canvas_mapview_init = gui_canvas_mapview_init; funcs->canvas_copy = gui_canvas_copy; funcs->canvas_put_sprite = gui_canvas_put_sprite; funcs->canvas_put_sprite_full = gui_canvas_put_sprite_full; diff --git a/client/gui_interface.c b/client/gui_interface.c index b043d29af7..5962a2fcc1 100644 --- a/client/gui_interface.c +++ b/client/gui_interface.c @@ -209,6 +209,14 @@ bool has_zoom_support(void) return funcs.has_zoom_support(); } +/************************************************************************** + Call canvas_mapview_init callback +**************************************************************************/ +void canvas_mapview_init(struct canvas *store) +{ + funcs.canvas_mapview_init(store); +} + /************************************************************************** Call canvas_copy callback **************************************************************************/ diff --git a/client/gui_interface.h b/client/gui_interface.h index d177e8baf6..096c50f2aa 100644 --- a/client/gui_interface.h +++ b/client/gui_interface.h @@ -62,6 +62,7 @@ struct gui_funcs { void (*canvas_free)(struct canvas *store); void (*canvas_set_zoom)(struct canvas *store, float zoom); bool (*has_zoom_support)(void); + void (*canvas_mapview_init)(struct canvas *store); void (*canvas_copy)(struct canvas *dest, struct canvas *src, int src_x, int src_y, int dest_x, int dest_y, int width, int height); diff --git a/client/include/canvas_g.h b/client/include/canvas_g.h index 155212ae2d..be6bc1152a 100644 --- a/client/include/canvas_g.h +++ b/client/include/canvas_g.h @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 1996-2005 - Freeciv Development Team This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,6 +33,8 @@ GUI_FUNC_PROTO(void, canvas_free, struct canvas *store) GUI_FUNC_PROTO(void, canvas_set_zoom, struct canvas *store, float zoom) GUI_FUNC_PROTO(bool, has_zoom_support, void) +GUI_FUNC_PROTO(void, canvas_mapview_init, struct canvas *store); + /* Drawing functions */ GUI_FUNC_PROTO(void, canvas_copy, struct canvas *dest, struct canvas *src, int src_x, int src_y, int dest_x, int dest_y, diff --git a/client/mapview_common.c b/client/mapview_common.c index 605ac01f9a..5e4b1c445b 100644 --- a/client/mapview_common.c +++ b/client/mapview_common.c @@ -3578,12 +3578,14 @@ bool map_canvas_resized(int width, int height) } mapview.store = canvas_create(full_width, full_height); canvas_set_zoom(mapview.store, map_zoom); + canvas_mapview_init(mapview.store); canvas_put_rectangle(mapview.store, get_color(tileset, COLOR_MAPVIEW_UNKNOWN), 0, 0, full_width / map_zoom, full_height / map_zoom); mapview.tmp_store = canvas_create(full_width, full_height); canvas_set_zoom(mapview.tmp_store, map_zoom); + canvas_mapview_init(mapview.tmp_store); } if (map_exists() && can_client_change_view()) { -- 2.30.1