From 7f5cd8a7aa9750d2b1a9cf9a14595b0a51dcd6aa Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sun, 21 Jul 2024 19:41:46 +0000 Subject: [PATCH] newSurface method now accepts Point instead of two integers --- client/media/CVideoHandler.cpp | 2 +- client/render/Canvas.cpp | 2 +- client/renderSDL/CursorHardware.cpp | 2 +- client/renderSDL/CursorSoftware.cpp | 2 +- client/renderSDL/SDL_Extensions.cpp | 12 ++++++------ client/renderSDL/SDL_Extensions.h | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/client/media/CVideoHandler.cpp b/client/media/CVideoHandler.cpp index 6c104c7c8..b2f8d2f5d 100644 --- a/client/media/CVideoHandler.cpp +++ b/client/media/CVideoHandler.cpp @@ -207,7 +207,7 @@ void CVideoInstance::prepareOutput(bool scaleToScreenSize, bool useTextureOutput } else { - surface = CSDL_Ext::newSurface(dimensions.x, dimensions.y); + surface = CSDL_Ext::newSurface(dimensions); sws = sws_getContext(getCodecContext()->width, getCodecContext()->height, getCodecContext()->pix_fmt, dimensions.x, dimensions.y, AV_PIX_FMT_RGB32, SWS_BICUBIC, nullptr, nullptr, nullptr); diff --git a/client/render/Canvas.cpp b/client/render/Canvas.cpp index dbb46b9f0..92f8d33d9 100644 --- a/client/render/Canvas.cpp +++ b/client/render/Canvas.cpp @@ -48,7 +48,7 @@ Canvas::Canvas(const Canvas & other, const Rect & newClipRect): Canvas::Canvas(const Point & size): renderArea(Point(0,0), size), - surface(CSDL_Ext::newSurface(size.x, size.y)) + surface(CSDL_Ext::newSurface(size)) { CSDL_Ext::fillSurface(surface, CSDL_Ext::toSDL(Colors::TRANSPARENCY) ); SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE); diff --git a/client/renderSDL/CursorHardware.cpp b/client/renderSDL/CursorHardware.cpp index dc42f9e38..619eab0d5 100644 --- a/client/renderSDL/CursorHardware.cpp +++ b/client/renderSDL/CursorHardware.cpp @@ -45,7 +45,7 @@ void CursorHardware::setVisible(bool on) void CursorHardware::setImage(std::shared_ptr image, const Point & pivotOffset) { - auto cursorSurface = CSDL_Ext::newSurface(image->dimensions().x, image->dimensions().y); + auto cursorSurface = CSDL_Ext::newSurface(image->dimensions()); CSDL_Ext::fillSurface(cursorSurface, CSDL_Ext::toSDL(Colors::TRANSPARENCY)); diff --git a/client/renderSDL/CursorSoftware.cpp b/client/renderSDL/CursorSoftware.cpp index 29b606b96..cc3cd0c5a 100644 --- a/client/renderSDL/CursorSoftware.cpp +++ b/client/renderSDL/CursorSoftware.cpp @@ -44,7 +44,7 @@ void CursorSoftware::createTexture(const Point & dimensions) if (cursorSurface) SDL_FreeSurface(cursorSurface); - cursorSurface = CSDL_Ext::newSurface(dimensions.x, dimensions.y); + cursorSurface = CSDL_Ext::newSurface(dimensions); cursorTexture = SDL_CreateTexture(mainRenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, dimensions.x, dimensions.y); SDL_SetSurfaceBlendMode(cursorSurface, SDL_BLENDMODE_NONE); diff --git a/client/renderSDL/SDL_Extensions.cpp b/client/renderSDL/SDL_Extensions.cpp index 5987e7d6c..f2dd2b5ad 100644 --- a/client/renderSDL/SDL_Extensions.cpp +++ b/client/renderSDL/SDL_Extensions.cpp @@ -63,21 +63,21 @@ void CSDL_Ext::setAlpha(SDL_Surface * bg, int value) SDL_SetSurfaceAlphaMod(bg, value); } -SDL_Surface * CSDL_Ext::newSurface(int w, int h) +SDL_Surface * CSDL_Ext::newSurface(const Point & dimensions) { - return newSurface(w, h, screen); + return newSurface(dimensions, screen); } -SDL_Surface * CSDL_Ext::newSurface(int w, int h, SDL_Surface * mod) //creates new surface, with flags/format same as in surface given +SDL_Surface * CSDL_Ext::newSurface(const Point & dimensions, SDL_Surface * mod) //creates new surface, with flags/format same as in surface given { - SDL_Surface * ret = SDL_CreateRGBSurface(0,w,h,mod->format->BitsPerPixel,mod->format->Rmask,mod->format->Gmask,mod->format->Bmask,mod->format->Amask); + SDL_Surface * ret = SDL_CreateRGBSurface(0,dimensions.x,dimensions.y,mod->format->BitsPerPixel,mod->format->Rmask,mod->format->Gmask,mod->format->Bmask,mod->format->Amask); if(ret == nullptr) { const char * error = SDL_GetError(); std::string messagePattern = "Failed to create SDL Surface of size %d x %d, %d bpp. Reason: %s"; - std::string message = boost::str(boost::format(messagePattern) % w % h % mod->format->BitsPerPixel % error); + std::string message = boost::str(boost::format(messagePattern) % dimensions.x % dimensions.y % mod->format->BitsPerPixel % error); handleFatalError(message, true); } @@ -631,7 +631,7 @@ SDL_Surface * CSDL_Ext::scaleSurface(SDL_Surface * surf, int width, int height) return nullptr; SDL_Surface * intermediate = SDL_ConvertSurface(surf, screen->format, 0); - SDL_Surface * ret = newSurface(width, height, intermediate); + SDL_Surface * ret = newSurface(Point(width, height), intermediate); #if SDL_VERSION_ATLEAST(2,0,16) SDL_SoftStretchLinear(intermediate, nullptr, ret, nullptr); diff --git a/client/renderSDL/SDL_Extensions.h b/client/renderSDL/SDL_Extensions.h index 9b1dec1aa..339a0cc88 100644 --- a/client/renderSDL/SDL_Extensions.h +++ b/client/renderSDL/SDL_Extensions.h @@ -84,8 +84,8 @@ using TColorPutterAlpha = void (*)(uint8_t *&, const uint8_t &, const uint8_t &, void drawBorder(SDL_Surface * sur, int x, int y, int w, int h, const SDL_Color & color, int depth = 1); void drawBorder(SDL_Surface * sur, const Rect & r, const SDL_Color & color, int depth = 1); - SDL_Surface * newSurface(int w, int h, SDL_Surface * mod); //creates new surface, with flags/format same as in surface given - SDL_Surface * newSurface(int w, int h); //creates new surface, with flags/format same as in screen surface + SDL_Surface * newSurface(const Point & dimensions, SDL_Surface * mod); //creates new surface, with flags/format same as in surface given + SDL_Surface * newSurface(const Point & dimensions); //creates new surface, with flags/format same as in screen surface SDL_Surface * copySurface(SDL_Surface * mod); //returns copy of given surface template SDL_Surface * createSurfaceWithBpp(int width, int height); //create surface with give bits per pixels value