mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-02 00:10:22 +02:00
newSurface method now accepts Point instead of two integers
This commit is contained in:
parent
20ba63bba3
commit
7f5cd8a7aa
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -45,7 +45,7 @@ void CursorHardware::setVisible(bool on)
|
||||
|
||||
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));
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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<int bpp>
|
||||
SDL_Surface * createSurfaceWithBpp(int width, int height); //create surface with give bits per pixels value
|
||||
|
Loading…
Reference in New Issue
Block a user