mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-04-22 06:02:04 +02:00
Change the create Bitmap from surface constructor to always take ownership of the surface, and provide an option to leave it as a mega surface
This commit is contained in:
parent
bd01e11f56
commit
c89f3d5bd7
2 changed files with 7 additions and 15 deletions
|
@ -621,7 +621,7 @@ Bitmap::Bitmap(const char *filename)
|
||||||
|
|
||||||
SDL_Surface *imgSurf = handler.surface;
|
SDL_Surface *imgSurf = handler.surface;
|
||||||
|
|
||||||
initFromSurface(imgSurf, hiresBitmap, true);
|
initFromSurface(imgSurf, hiresBitmap, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap::Bitmap(int width, int height, bool isHires)
|
Bitmap::Bitmap(int width, int height, bool isHires)
|
||||||
|
@ -789,7 +789,7 @@ Bitmap::Bitmap(TEXFBO &other)
|
||||||
p->addTaintedArea(rect());
|
p->addTaintedArea(rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap::Bitmap(SDL_Surface *imgSurf, SDL_Surface *imgSurfHires)
|
Bitmap::Bitmap(SDL_Surface *imgSurf, SDL_Surface *imgSurfHires, bool forceMega)
|
||||||
{
|
{
|
||||||
Bitmap *hiresBitmap = nullptr;
|
Bitmap *hiresBitmap = nullptr;
|
||||||
|
|
||||||
|
@ -799,7 +799,7 @@ Bitmap::Bitmap(SDL_Surface *imgSurf, SDL_Surface *imgSurfHires)
|
||||||
hiresBitmap->setLores(this);
|
hiresBitmap->setLores(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
initFromSurface(imgSurf, hiresBitmap, false);
|
initFromSurface(imgSurf, hiresBitmap, forceMega);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap::~Bitmap()
|
Bitmap::~Bitmap()
|
||||||
|
@ -807,18 +807,14 @@ Bitmap::~Bitmap()
|
||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bitmap::initFromSurface(SDL_Surface *imgSurf, Bitmap *hiresBitmap, bool freeSurface)
|
void Bitmap::initFromSurface(SDL_Surface *imgSurf, Bitmap *hiresBitmap, bool forceMega)
|
||||||
{
|
{
|
||||||
p->ensureFormat(imgSurf, SDL_PIXELFORMAT_ABGR8888);
|
p->ensureFormat(imgSurf, SDL_PIXELFORMAT_ABGR8888);
|
||||||
|
|
||||||
if (imgSurf->w > glState.caps.maxTexSize || imgSurf->h > glState.caps.maxTexSize)
|
if (imgSurf->w > glState.caps.maxTexSize || imgSurf->h > glState.caps.maxTexSize || forceMega)
|
||||||
{
|
{
|
||||||
/* Mega surface */
|
/* Mega surface */
|
||||||
|
|
||||||
if(!freeSurface) {
|
|
||||||
throw Exception(Exception::RGSSError, "Cloning Mega Bitmap from Surface not supported");
|
|
||||||
}
|
|
||||||
|
|
||||||
p = new BitmapPrivate(this);
|
p = new BitmapPrivate(this);
|
||||||
p->selfHires = hiresBitmap;
|
p->selfHires = hiresBitmap;
|
||||||
p->megaSurface = imgSurf;
|
p->megaSurface = imgSurf;
|
||||||
|
@ -848,10 +844,6 @@ void Bitmap::initFromSurface(SDL_Surface *imgSurf, Bitmap *hiresBitmap, bool fre
|
||||||
|
|
||||||
TEX::bind(p->gl.tex);
|
TEX::bind(p->gl.tex);
|
||||||
TEX::uploadImage(p->gl.width, p->gl.height, imgSurf->pixels, GL_RGBA);
|
TEX::uploadImage(p->gl.width, p->gl.height, imgSurf->pixels, GL_RGBA);
|
||||||
|
|
||||||
if (freeSurface) {
|
|
||||||
SDL_FreeSurface(imgSurf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p->addTaintedArea(rect());
|
p->addTaintedArea(rect());
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
Bitmap(int width, int height, bool isHires = false);
|
Bitmap(int width, int height, bool isHires = false);
|
||||||
Bitmap(void *pixeldata, int width, int height);
|
Bitmap(void *pixeldata, int width, int height);
|
||||||
Bitmap(TEXFBO &other);
|
Bitmap(TEXFBO &other);
|
||||||
Bitmap(SDL_Surface *imgSurf, SDL_Surface *imgSurfHires);
|
Bitmap(SDL_Surface *imgSurf, SDL_Surface *imgSurfHires, bool forceMega = false);
|
||||||
|
|
||||||
/* Clone constructor */
|
/* Clone constructor */
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public:
|
||||||
Bitmap(const Bitmap &other, int frame = -2);
|
Bitmap(const Bitmap &other, int frame = -2);
|
||||||
~Bitmap();
|
~Bitmap();
|
||||||
|
|
||||||
void initFromSurface(SDL_Surface *imgSurf, Bitmap *hiresBitmap, bool freeSurface);
|
void initFromSurface(SDL_Surface *imgSurf, Bitmap *hiresBitmap, bool forceMega = false);
|
||||||
|
|
||||||
int width() const;
|
int width() const;
|
||||||
int height() const;
|
int height() const;
|
||||||
|
|
Loading…
Add table
Reference in a new issue