mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-10 11:51:52 +00:00
STARK: Don't store the image size twice
This commit is contained in:
parent
defa657429
commit
2561233424
@ -41,9 +41,7 @@ VisualImageXMG::VisualImageXMG(Gfx::Driver *gfx) :
|
||||
Visual(TYPE),
|
||||
_gfx(gfx),
|
||||
_texture(nullptr),
|
||||
_surface(nullptr),
|
||||
_width(0),
|
||||
_height(0) {
|
||||
_surface(nullptr) {
|
||||
_surfaceRenderer = _gfx->createSurfaceRenderer();
|
||||
}
|
||||
|
||||
@ -61,12 +59,10 @@ void VisualImageXMG::setHotSpot(const Common::Point &hotspot) {
|
||||
}
|
||||
|
||||
void VisualImageXMG::load(Common::ReadStream *stream) {
|
||||
delete _texture;
|
||||
assert(!_surface && !_texture);
|
||||
|
||||
// Decode the XMG
|
||||
_surface = Formats::XMGDecoder::decode(stream);
|
||||
_width = _surface->w;
|
||||
_height = _surface->h;
|
||||
_texture = _gfx->createTexture(_surface);
|
||||
}
|
||||
|
||||
@ -76,7 +72,9 @@ void VisualImageXMG::render(const Common::Point &position, bool useOffset) {
|
||||
}
|
||||
|
||||
bool VisualImageXMG::isPointSolid(const Common::Point &point) const {
|
||||
if (_width < 32 && _height < 32) {
|
||||
assert(_surface);
|
||||
|
||||
if (_surface->w < 32 && _surface->h < 32) {
|
||||
return true; // Small images are always solid
|
||||
}
|
||||
|
||||
@ -85,4 +83,14 @@ bool VisualImageXMG::isPointSolid(const Common::Point &point) const {
|
||||
return ((*ptr) & 0xFF000000) == 0xFF000000;
|
||||
}
|
||||
|
||||
int VisualImageXMG::getWidth() const {
|
||||
assert(_surface);
|
||||
return _surface->w;
|
||||
}
|
||||
|
||||
int VisualImageXMG::getHeight() const {
|
||||
assert(_surface);
|
||||
return _surface->h;
|
||||
}
|
||||
|
||||
} // End of namespace Stark
|
||||
|
@ -60,11 +60,13 @@ public:
|
||||
/** Perform a transparency hit test on an image point */
|
||||
bool isPointSolid(const Common::Point &point) const;
|
||||
|
||||
int getWidth() const { return _width; }
|
||||
int getHeight() const { return _height; }
|
||||
/** Get the width in pixels */
|
||||
int getWidth() const;
|
||||
|
||||
/** Get the height in pixels */
|
||||
int getHeight() const;
|
||||
|
||||
private:
|
||||
int _width;
|
||||
int _height;
|
||||
Gfx::Driver *_gfx;
|
||||
Gfx::SurfaceRenderer *_surfaceRenderer;
|
||||
Gfx::Texture *_texture;
|
||||
|
Loading…
Reference in New Issue
Block a user