mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-03 09:23:37 +00:00
GLK: Add picture scaling
This commit is contained in:
parent
bd86fd7bbf
commit
5a05140ac3
@ -126,6 +126,21 @@ Picture *Pictures::load(uint32 id) {
|
|||||||
return pic;
|
return pic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Picture *Pictures::scale(Picture *src, size_t sx, size_t sy) {
|
||||||
|
// Check for the presence of an already scaled version of that size
|
||||||
|
Picture *dst = retrieve(src->_id, true);
|
||||||
|
if (dst && dst->w == sx && dst->h == sy)
|
||||||
|
return dst;
|
||||||
|
|
||||||
|
// Create a new picture of the destination size and rescale the source picture
|
||||||
|
dst = new Picture(sx, sy, src->format);
|
||||||
|
dst->_id = src->_id;
|
||||||
|
dst->_scaled = true;
|
||||||
|
dst->transBlitFrom(*src, src->getBounds(), dst->getBounds(), (uint)-1);
|
||||||
|
|
||||||
|
storeScaled(dst);
|
||||||
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
void Picture::increment() {
|
void Picture::increment() {
|
||||||
@ -139,11 +154,6 @@ void Picture::decrement() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Picture *Picture::scale(int sx, int sy) {
|
|
||||||
// TODO: gli_picture_scale
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Picture::drawPicture(int x0, int y0, int dx0, int dy0, int dx1, int dy1) {
|
void Picture::drawPicture(int x0, int y0, int dx0, int dy0, int dx1, int dy1) {
|
||||||
// TODO: drawPicture
|
// TODO: drawPicture
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,13 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
Picture() : Graphics::ManagedSurface(), _refCount(0), _id(0), _scaled(0) {}
|
Picture() : Graphics::ManagedSurface(), _refCount(0), _id(0), _scaled(false) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
Picture(int width, int height, const Graphics::PixelFormat &format) :
|
||||||
|
Graphics::ManagedSurface(width, height, format), _refCount(0), _id(0), _scaled(false) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increment reference counter
|
* Increment reference counter
|
||||||
@ -52,11 +58,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
void decrement();
|
void decrement();
|
||||||
|
|
||||||
/**
|
|
||||||
* Rescale the picture to a new picture of a given size
|
|
||||||
*/
|
|
||||||
Picture *scale(int sx, int sy);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw the picture
|
* Draw the picture
|
||||||
*/
|
*/
|
||||||
@ -134,6 +135,11 @@ public:
|
|||||||
* Load a given picture
|
* Load a given picture
|
||||||
*/
|
*/
|
||||||
Picture *load(uint32 id);
|
Picture *load(uint32 id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rescale the passed picture to a new picture of a given size
|
||||||
|
*/
|
||||||
|
Picture *scale(Picture *src, size_t sx, size_t sy);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Glk
|
} // End of namespace Glk
|
||||||
|
@ -186,7 +186,7 @@ void GraphicsWindow::drawPicture(Picture *src, int x0, int y0, int width, int h
|
|||||||
int w, h;
|
int w, h;
|
||||||
|
|
||||||
if (width != src->w || height != src->h) {
|
if (width != src->w || height != src->h) {
|
||||||
src = src->scale(width, height);
|
src = g_vm->_pictures->scale(src, width, height);
|
||||||
if (!src)
|
if (!src)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,7 @@ glui32 TextBufferWindow::drawPicture(glui32 image, glui32 align, glui32 scaled,
|
|||||||
|
|
||||||
if (scaled) {
|
if (scaled) {
|
||||||
Picture *tmp;
|
Picture *tmp;
|
||||||
tmp = pic->scale(width, height);
|
tmp = g_vm->_pictures->scale(pic, width, height);
|
||||||
pic = tmp;
|
pic = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user