TITANIC: Adding more video surface methods

This commit is contained in:
Paul Gilbert 2016-07-03 13:52:09 -04:00
parent d9e05e215c
commit 5ab33f117a
4 changed files with 92 additions and 9 deletions

View File

@ -36,7 +36,7 @@ void CJPEGDecode::decode(OSVideoSurface &surface, const CString &name) {
// Resize the surface if necessary
if (!surface.hasSurface() || surface.getWidth() != srcSurf->w
|| surface.getHeight() != srcSurf->h)
surface.resize(srcSurf->w, srcSurf->h);
surface.recreate(srcSurf->w, srcSurf->h);
// Convert the decoded surface to the correct pixel format, and then copy it over
surface.lock();
@ -63,7 +63,7 @@ void CTargaDecode::decode(OSVideoSurface &surface, const CString &name) {
// Resize the surface if necessary
if (!surface.hasSurface() || surface.getWidth() != srcSurf->w
|| surface.getHeight() != srcSurf->h)
surface.resize(srcSurf->w, srcSurf->h);
surface.recreate(srcSurf->w, srcSurf->h);
// Convert the decoded surface to the correct pixel format, and then copy it over
surface.lock();

View File

@ -175,7 +175,7 @@ void OSMovie::decodeFrame() {
// If the video surface doesn't yet have an underlying surface, create it
if (!videoSurface->hasSurface())
videoSurface->resize(frame->w, frame->h);
videoSurface->recreate(frame->w, frame->h);
// Lock access to the surface
videoSurface->lock();

View File

@ -296,7 +296,14 @@ int OSVideoSurface::getPitch() {
return _ddSurface->getPitch();
}
void OSVideoSurface::resize(int width, int height) {
int OSVideoSurface::getBpp() {
if (!loadIfReady())
error("Could not load resource");
return getPixelDepth();
}
void OSVideoSurface::recreate(int width, int height) {
freeSurface();
_screenManager->resizeSurface(this, width, height);
@ -304,9 +311,19 @@ void OSVideoSurface::resize(int width, int height) {
_videoSurfaceCounter += _ddSurface->getSize();
}
void OSVideoSurface::resize(int width, int height) {
if (!_ddSurface || _ddSurface->getWidth() != width ||
_ddSurface->getHeight() != height)
recreate(width, height);
}
void OSVideoSurface::detachSurface() {
_ddSurface = nullptr;
}
int OSVideoSurface::getPixelDepth() {
if (!loadIfReady())
assert(0);
error("Could not load resource");
lock();
@ -360,6 +377,13 @@ uint16 OSVideoSurface::getPixel(const Common::Point &pt) {
}
}
void OSVideoSurface::setPixel(const Point &pt, uint pixel) {
assert(getPixelDepth() == 2);
uint16 *pixelP = (uint16 *)_rawSurface->getBasePtr(pt.x, pt.y);
*pixelP = pixel;
}
void OSVideoSurface::changePixel(uint16 *pixelP, uint16 *color, byte srcVal, bool remapFlag) {
assert(getPixelDepth() == 2);
const Graphics::PixelFormat &destFormat = _ddSurface->getFormat();
@ -391,9 +415,17 @@ void OSVideoSurface::shiftColors() {
// we already convert 16-bit surfaces as soon as they're loaded
}
void OSVideoSurface::clear() {
if (!loadIfReady())
error("Could not load resource");
}
void OSVideoSurface::playMovie(uint flags, CVideoSurface *surface) {
if (loadIfReady() && _movie)
_movie->play(flags, surface);
_ddSurface->fill(nullptr, 0);
}
void OSVideoSurface::playMovie(uint startFrame, uint endFrame, int v3, bool v4) {

View File

@ -129,12 +129,27 @@ public:
* Returns the pitch of the surface in bytes
*/
virtual int getPitch() = 0;
/**
* Reiszes the surface
* Returns the bytes per pixel of the surface
*/
virtual int getBpp() = 0;
/**
* Recreates the surface
*/
virtual void recreate(int width, int height) = 0;
/**
* Resizes the surface
*/
virtual void resize(int width, int height) = 0;
/**
* Detachs the underlying raw surface
*/
virtual void detachSurface() = 0;
/**
* Returns the number of bytes per pixel in the surface
*/
@ -145,6 +160,12 @@ public:
*/
virtual uint16 getPixel(const Common::Point &pt) = 0;
/**
* Sets a pixel at a specified position within the surface
*/
virtual void setPixel(const Point &pt, uint pixel) = 0;
/**
* Change a pixel
*/
@ -155,6 +176,11 @@ public:
*/
virtual void shiftColors() = 0;
/**
* Clears the entire surface to black
*/
virtual void clear() = 0;
/**
* Plays a movie, loading it from the specified _resource
* if not already loaded
@ -305,10 +331,25 @@ public:
virtual int getPitch();
/**
* Reiszes the surface
* Returns the bytes per pixel of the surface
*/
virtual int getBpp();
/**
* Recreates the surface with the designated size
*/
virtual void recreate(int width, int height);
/**
* Resizes the surface
*/
virtual void resize(int width, int height);
/**
* Detachs the underlying raw surface
*/
virtual void detachSurface();
/**
* Returns the number of bytes per pixel in the surface
*/
@ -317,7 +358,12 @@ public:
/**
* Gets the pixel at the specified position within the surface
*/
virtual uint16 getPixel(const Common::Point &pt);
virtual uint16 getPixel(const Point &pt);
/**
* Sets a pixel at a specified position within the surface
*/
virtual void setPixel(const Point &pt, uint pixel);
/**
* Change a pixel
@ -329,6 +375,11 @@ public:
*/
virtual void shiftColors();
/**
* Clears the entire surface to black
*/
virtual void clear();
/**
* Plays a movie, loading it from the specified _resource
* if not already loaded