From 1e1b208b821779621f70191778d27bc6334b3f07 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 27 Feb 2021 23:37:15 +0200 Subject: [PATCH 11/11] 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-3.0/canvas.c | 7 +++++++ client/gui-gtk-3.22/canvas.c | 7 +++++++ client/gui-gtk-4.0/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-sdl2/canvas.c | 8 ++++++++ client/gui-stub/canvas.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 ++ 13 files changed, 60 insertions(+), 1 deletion(-) diff --git a/client/gui-gtk-3.0/canvas.c b/client/gui-gtk-3.0/canvas.c index 164482aa5d..ffce5e7b5c 100644 --- a/client/gui-gtk-3.0/canvas.c +++ b/client/gui-gtk-3.0/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-gtk-3.22/canvas.c b/client/gui-gtk-3.22/canvas.c index c36518457c..c55e94b769 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-gtk-4.0/canvas.c b/client/gui-gtk-4.0/canvas.c index ec9f7e25eb..0ca85aebf8 100644 --- a/client/gui-gtk-4.0/canvas.c +++ b/client/gui-gtk-4.0/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 00fa1b8f52..070a841397 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 077def75ad..67bbdb3164 100644 --- a/client/gui-qt/qtg_cxxside.cpp +++ b/client/gui-qt/qtg_cxxside.cpp @@ -56,6 +56,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 19e3225d1a..ee2b27407e 100644 --- a/client/gui-qt/qtg_cxxside.h +++ b/client/gui-qt/qtg_cxxside.h @@ -60,6 +60,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-sdl2/canvas.c b/client/gui-sdl2/canvas.c index efd3ef98e3..e58eb81752 100644 --- a/client/gui-sdl2/canvas.c +++ b/client/gui-sdl2/canvas.c @@ -75,6 +75,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 a6ade1ee36..66cf353694 100644 --- a/client/gui-stub/canvas.c +++ b/client/gui-stub/canvas.c @@ -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_cbsetter.c b/client/gui_cbsetter.c index 55092c04bd..ae4292adfd 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 ece4ba45c8..927e3c82c1 100644 --- a/client/gui_interface.c +++ b/client/gui_interface.c @@ -217,6 +217,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 b1f4673c1e..c64603c581 100644 --- a/client/gui_interface.h +++ b/client/gui_interface.h @@ -63,6 +63,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 19495ec34c..646c0cc300 100644 --- a/client/mapview_common.c +++ b/client/mapview_common.c @@ -3571,12 +3571,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_is_empty() && can_client_change_view()) { -- 2.30.1