Browse Source

newSurface method now accepts Point instead of two integers

Ivan Savenko 1 year ago
parent
commit
7f5cd8a7aa

+ 1 - 1
client/media/CVideoHandler.cpp

@@ -207,7 +207,7 @@ void CVideoInstance::prepareOutput(bool scaleToScreenSize, bool useTextureOutput
 	}
 	}
 	else
 	else
 	{
 	{
-		surface = CSDL_Ext::newSurface(dimensions.x, dimensions.y);
+		surface = CSDL_Ext::newSurface(dimensions);
 		sws = sws_getContext(getCodecContext()->width, getCodecContext()->height, getCodecContext()->pix_fmt,
 		sws = sws_getContext(getCodecContext()->width, getCodecContext()->height, getCodecContext()->pix_fmt,
 							 dimensions.x, dimensions.y, AV_PIX_FMT_RGB32,
 							 dimensions.x, dimensions.y, AV_PIX_FMT_RGB32,
 							 SWS_BICUBIC, nullptr, nullptr, nullptr);
 							 SWS_BICUBIC, nullptr, nullptr, nullptr);

+ 1 - 1
client/render/Canvas.cpp

@@ -48,7 +48,7 @@ Canvas::Canvas(const Canvas & other, const Rect & newClipRect):
 
 
 Canvas::Canvas(const Point & size):
 Canvas::Canvas(const Point & size):
 	renderArea(Point(0,0), 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) );
 	CSDL_Ext::fillSurface(surface, CSDL_Ext::toSDL(Colors::TRANSPARENCY) );
 	SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE);
 	SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE);

+ 1 - 1
client/renderSDL/CursorHardware.cpp

@@ -45,7 +45,7 @@ void CursorHardware::setVisible(bool on)
 
 
 void CursorHardware::setImage(std::shared_ptr<IImage> image, const Point & pivotOffset)
 void CursorHardware::setImage(std::shared_ptr<IImage> 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));
 	CSDL_Ext::fillSurface(cursorSurface, CSDL_Ext::toSDL(Colors::TRANSPARENCY));
 
 

+ 1 - 1
client/renderSDL/CursorSoftware.cpp

@@ -44,7 +44,7 @@ void CursorSoftware::createTexture(const Point & dimensions)
 	if (cursorSurface)
 	if (cursorSurface)
 		SDL_FreeSurface(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);
 	cursorTexture = SDL_CreateTexture(mainRenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, dimensions.x, dimensions.y);
 
 
 	SDL_SetSurfaceBlendMode(cursorSurface, SDL_BLENDMODE_NONE);
 	SDL_SetSurfaceBlendMode(cursorSurface, SDL_BLENDMODE_NONE);

+ 6 - 6
client/renderSDL/SDL_Extensions.cpp

@@ -63,21 +63,21 @@ void CSDL_Ext::setAlpha(SDL_Surface * bg, int value)
 	SDL_SetSurfaceAlphaMod(bg, 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)
 	if(ret == nullptr)
 	{
 	{
 		const char * error = SDL_GetError();
 		const char * error = SDL_GetError();
 
 
 		std::string messagePattern = "Failed to create SDL Surface of size %d x %d, %d bpp. Reason: %s";
 		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);
 		handleFatalError(message, true);
 	}
 	}
@@ -631,7 +631,7 @@ SDL_Surface * CSDL_Ext::scaleSurface(SDL_Surface * surf, int width, int height)
 		return nullptr;
 		return nullptr;
 
 
 	SDL_Surface * intermediate = SDL_ConvertSurface(surf, screen->format, 0);
 	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)
 #if SDL_VERSION_ATLEAST(2,0,16)
 	SDL_SoftStretchLinear(intermediate, nullptr, ret, nullptr);
 	SDL_SoftStretchLinear(intermediate, nullptr, ret, nullptr);

+ 2 - 2
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, 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);
 	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
 	SDL_Surface * copySurface(SDL_Surface * mod); //returns copy of given surface
 	template<int bpp>
 	template<int bpp>
 	SDL_Surface * createSurfaceWithBpp(int width, int height); //create surface with give bits per pixels value
 	SDL_Surface * createSurfaceWithBpp(int width, int height); //create surface with give bits per pixels value