sdl/rect: Move fill_surface_rect to sdl/utils.hpp

And then have to clean up over a dozen files that were relying on
sdl/rect.hpp including sdl/utils.hpp and various other side effects.
This commit is contained in:
Tommy 2022-06-29 00:49:15 +12:00
parent c2e23b64f6
commit 132a45c52f
16 changed files with 33 additions and 21 deletions

View File

@ -19,6 +19,7 @@
*/
#include "arrow.hpp"
#include "color.hpp"
#include "cursor.hpp"
#include "display.hpp"
#include "draw.hpp"
@ -28,6 +29,7 @@
#include "font/text.hpp"
#include "preferences/game.hpp"
#include "gettext.hpp"
#include "gui/dialogs/loading_screen.hpp"
#include "halo.hpp"
#include "hotkey/command_executor.hpp"
#include "language.hpp"
@ -39,7 +41,8 @@
#include "play_controller.hpp" //note: this can probably be refactored out
#include "reports.hpp"
#include "resources.hpp"
#include "color.hpp"
#include "sdl/utils.hpp" // fill_surface_rect
#include "show_dialog.hpp"
#include "synced_context.hpp"
#include "team.hpp"
#include "terrain/builder.hpp"
@ -51,8 +54,6 @@
#include "units/drawer.hpp"
#include "units/orb_status.hpp"
#include "whiteboard/manager.hpp"
#include "show_dialog.hpp"
#include "gui/dialogs/loading_screen.hpp"
#include <SDL2/SDL_image.h>

View File

@ -849,7 +849,7 @@ public:
void render_image(int x, int y, const display::drawing_layer drawing_layer,
const map_location& loc, const image::locator& i_locator,
bool hreverse=false, bool greyscale=false,
int32_t alpha=floating_to_fixed_point(1.0), color_t blendto = {0,0,0},
int32_t alpha=SDL_ALPHA_OPAQUE, color_t blendto = {0,0,0},
double blend_ratio=0, double submerged=0.0,bool vreverse =false);
/**

View File

@ -19,6 +19,7 @@
#include "sdl/rect.hpp"
#include "sdl/surface.hpp"
#include "sdl/texture.hpp"
#include "sdl/utils.hpp" // sdl::runtime_at_least
#include "video.hpp"
#include <SDL2/SDL_rect.h>

View File

@ -19,6 +19,7 @@
#include "draw.hpp"
#include "font/text.hpp"
#include "log.hpp"
#include "sdl/utils.hpp"
#include "video.hpp"
#include <map>

View File

@ -37,6 +37,7 @@
#include "font/standard_colors.hpp"
#include "reports.hpp"
#include "resources.hpp"
#include "sdl/utils.hpp"
#include "tod_manager.hpp"
#include "color.hpp"
#include "synced_context.hpp"

View File

@ -34,6 +34,7 @@
#include "sdl/point.hpp"
#include "sdl/rect.hpp"
#include "sdl/texture.hpp"
#include "sdl/utils.hpp" // blur_surface
#include "video.hpp"
#include "wml_exception.hpp"

View File

@ -18,15 +18,16 @@
#include "gui/dialogs/campaign_difficulty.hpp"
#include "config.hpp"
#include "deprecation.hpp"
#include "font/text_formatting.hpp"
#include "formatter.hpp"
#include "game_version.hpp"
#include "gui/auxiliary/find_widget.hpp"
#include "preferences/game.hpp"
#include "gui/widgets/listbox.hpp"
#include "gui/widgets/window.hpp"
#include "log.hpp"
#include "preferences/game.hpp"
#include "serialization/string_utils.hpp"
#include "deprecation.hpp"
static lg::log_domain log_wml("wml");
#define WRN_WML LOG_STREAM(warn, log_wml)

View File

@ -27,6 +27,7 @@
#include "sdl/rect.hpp"
#include "sound.hpp"
#include "gettext.hpp"
#include "utils/math.hpp"
#include "wml_exception.hpp"
#include <functional>

View File

@ -28,6 +28,7 @@
#include "preferences/general.hpp"
#include "resources.hpp"
#include "sdl/surface.hpp"
#include "sdl/utils.hpp"
#include "team.hpp"
#include "terrain/type_data.hpp"
#include "units/unit.hpp"

View File

@ -18,6 +18,8 @@
#include "sdl/window.hpp"
#include "video.hpp"
#include <iostream>
namespace sdl
{
bool point_in_rect(int x, int y, const SDL_Rect& rect)

View File

@ -20,12 +20,10 @@
* Contains the SDL_Rect helper code.
*/
#include "utils.hpp"
#include "sdl/point.hpp"
#include <SDL2/SDL_rect.h>
struct point;
namespace sdl
{
@ -89,18 +87,6 @@ SDL_Rect intersect_rects(const SDL_Rect& rect1, const SDL_Rect& rect2);
*/
SDL_Rect union_rects(const SDL_Rect &rect1, const SDL_Rect &rect2);
/**
* Fill a rectangle on a given surface. Alias for SDL_FillRect.
*
* @param dst The surface to operate on.
* @param dst_rect The rectangle to fill.
* @param color Color of the rectangle.
*/
inline void fill_surface_rect(surface& dst, SDL_Rect* dst_rect, const uint32_t color)
{
SDL_FillRect(dst, dst_rect, color);
}
} // namespace sdl
bool operator==(const SDL_Rect& a, const SDL_Rect& b);

View File

@ -14,6 +14,7 @@
#include "sdl/surface.hpp"
#include "color.hpp"
#include "draw.hpp" // for surface_restorer. Remove that then remove this.
#include "sdl/rect.hpp"
#include "video.hpp" // for surface_restorer. Remove that then remove this.

View File

@ -39,6 +39,18 @@ version_info get_version();
*/
bool runtime_at_least(uint8_t major, uint8_t minor = 0, uint8_t patch = 0);
/**
* Fill a rectangle on a given surface. Alias for SDL_FillRect.
*
* @param dst The surface to operate on.
* @param dst_rect The rectangle to fill.
* @param color Color of the rectangle.
*/
inline void fill_surface_rect(surface& dst, SDL_Rect* dst_rect, const uint32_t color)
{
SDL_FillRect(dst, dst_rect, color);
}
} // namespace sdl

View File

@ -29,6 +29,7 @@
#include "font/standard_colors.hpp"
#include "sdl/rect.hpp"
#include "sdl/input.hpp" // get_mouse_state
#include "sdl/utils.hpp" // blur_surface
static lg::log_domain log_display("display");
#define ERR_DP LOG_STREAM(err, log_display)

View File

@ -26,6 +26,7 @@
#include "picture.hpp"
#include "preferences/game.hpp"
#include "sdl/surface.hpp"
#include "sdl/utils.hpp" // scale_surface_nn, fill_surface_rect
#include "team.hpp"
#include "units/animation.hpp"
#include "units/animation_component.hpp"

View File

@ -18,6 +18,7 @@
#include "color.hpp"
#include "game_display.hpp"
#include "log.hpp"
#include "sdl/utils.hpp" // floating_to_fixed_point
#include "sound.hpp"
static lg::log_domain log_engine("engine");