Implemented the OSystem framebuffer API, as discussed on scummvm-devel. All changes are just fine, and won't cause any compile problems or regressions, despite the fact that I can't test most of the non-SDL backend changes, at an improbability level of two to the power of two hundred and seventy-six thousand to one against - possibly much higher. Anything you still can't cope with is therefore your own problem. Please relax.
svn-id: r27548
This commit is contained in:
parent
ab9b9a1bf3
commit
b51f2f3212
26 changed files with 217 additions and 144 deletions
|
@ -110,6 +110,8 @@ private:
|
|||
typedef void (OSystem_PalmOS5::*RendererProc)(RectangleType &r, PointType &p);
|
||||
RendererProc _render;
|
||||
|
||||
Graphics::Surface _framebuffer;
|
||||
|
||||
OverlayColor *_overlayP;
|
||||
WinHandle _overlayH, _workScreenH;
|
||||
int16 *_workScreenP;
|
||||
|
@ -168,7 +170,8 @@ public:
|
|||
|
||||
void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
|
||||
void clearScreen();
|
||||
bool grabRawScreen(Graphics::Surface *surf);
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
virtual void unlockScreen();
|
||||
|
||||
void setCursorPalette(const byte *colors, uint start, uint num);
|
||||
void disableCursorPalette(bool disable);
|
||||
|
|
|
@ -219,13 +219,18 @@ void OSystem_PalmOS5::copyRectToScreen(const byte *buf, int pitch, int x, int y,
|
|||
}
|
||||
}
|
||||
|
||||
bool OSystem_PalmOS5::grabRawScreen(Graphics::Surface *surf) {
|
||||
assert(surf);
|
||||
Graphics::Surface *OSystem_PalmOS5::lockScreen() {
|
||||
_framebuffer.pixels = _offScreenP;
|
||||
_framebuffer.w = _screenWidth;
|
||||
_framebuffer.h = _screenHeight;
|
||||
_framebuffer.pitch = _screenWidth;
|
||||
_framebuffer.bytesPerPixel = 1;
|
||||
|
||||
surf->create(_screenWidth, _screenHeight, 1);
|
||||
MemMove(surf->pixels, _offScreenP, _screenWidth * _screenHeight);
|
||||
return &_framebuffer;
|
||||
}
|
||||
|
||||
return true;
|
||||
void OSystem_PalmOS5::unlockScreen() {
|
||||
// The screen is always completely update anyway, so we don't have to force a full update here.
|
||||
}
|
||||
|
||||
void OSystem_PalmOS5::int_updateScreen() {
|
||||
|
|
|
@ -81,8 +81,8 @@ class OSystem_Dreamcast : public OSystem {
|
|||
// The screen will not be updated to reflect the new bitmap
|
||||
void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
|
||||
|
||||
// Copies the current screen contents to a new surface.
|
||||
bool grabRawScreen(Graphics::Surface *surf);
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
virtual void unlockScreen();
|
||||
|
||||
// Clear the screen to black.
|
||||
void clearScreen();
|
||||
|
@ -213,6 +213,8 @@ class OSystem_Dreamcast : public OSystem {
|
|||
void *ovl_tx[NUM_BUFFERS];
|
||||
unsigned short palette[256], cursor_palette[256];
|
||||
|
||||
Graphics::Surface _framebuffer;
|
||||
|
||||
int temp_sound_buffer[RING_BUFFER_SAMPLES>>SOUND_BUFFER_SHIFT];
|
||||
|
||||
void checkSound();
|
||||
|
|
|
@ -609,19 +609,24 @@ int OSystem_Dreamcast::getGraphicsMode() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool OSystem_Dreamcast::grabRawScreen(Graphics::Surface *surf)
|
||||
Graphics::Surface *OSystem_Dreamcast::lockScreen()
|
||||
{
|
||||
if(!screen || !surf)
|
||||
return false;
|
||||
if (!screen)
|
||||
return 0;
|
||||
|
||||
surf->create(_screen_w, _screen_h, 1);
|
||||
unsigned char *src = screen, *dst = (unsigned char *)surf->pixels;
|
||||
for(int h = _screen_h; h>0; --h) {
|
||||
memcpy(dst, src, _screen_w);
|
||||
src += SCREEN_W;
|
||||
dst += _screen_w;
|
||||
_framebuffer.pixels = screen;
|
||||
_framebuffer.w = _screen_w;
|
||||
_framebuffer.h = _screen_h;
|
||||
_framebuffer.pitch = SCREEN_W;
|
||||
_framebuffer.bytesPerPixel = 1;
|
||||
|
||||
return &_framebuffer;
|
||||
}
|
||||
return true;
|
||||
|
||||
void OSystem_Dreamcast::unlockScreen()
|
||||
{
|
||||
// Force screen update
|
||||
_screen_dirty = true;
|
||||
}
|
||||
|
||||
void OSystem_Dreamcast::clearScreen()
|
||||
|
|
|
@ -474,8 +474,13 @@ Common::SaveFileManager* OSystem_DS::getSavefileManager()
|
|||
}
|
||||
}
|
||||
|
||||
bool OSystem_DS::grabRawScreen(Graphics::Surface* surf) {
|
||||
surf->create(DS::getGameWidth(), DS::getGameHeight(), 1);
|
||||
Graphics::Surface *OSystem_DS::lockScreen() {
|
||||
// For now, we create a full temporary screen surface, to which we copy the
|
||||
// the screen content. Later unlockScreen will copy everything back.
|
||||
// Not very nice nor efficient, but at least works, and is not worse
|
||||
// than in the bad old times where we used grabRawScreen + copyRectToScreen.
|
||||
|
||||
_framebuffer.create(DS::getGameWidth(), DS::getGameHeight(), 1);
|
||||
|
||||
// Ensure we copy using 16 bit quantities due to limitation of VRAM addressing
|
||||
|
||||
|
@ -486,11 +491,19 @@ bool OSystem_DS::grabRawScreen(Graphics::Surface* surf) {
|
|||
DC_FlushRange(image + (y << 8), DS::getGameWidth());
|
||||
for (int x = 0; x < DS::getGameWidth() >> 1; x++)
|
||||
{
|
||||
*(((u16 *) (surf->pixels)) + y * (DS::getGameWidth() >> 1) + x) = image[y << 8 + x];
|
||||
*(((u16 *) (_framebuffer.pixels)) + y * (DS::getGameWidth() >> 1) + x) = image[y << 8 + x];
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return &_framebuffer;
|
||||
}
|
||||
|
||||
void OSystem_DS::unlockScreen() {
|
||||
// Copy temp framebuffer back to screen
|
||||
copyRectToScreen((byte *)_framebuffer.pixels, _framebuffer.pitch, 0, 0, _framebuffer.w, _framebuffer.h);
|
||||
|
||||
// Free memory
|
||||
_framebuffer.free();
|
||||
}
|
||||
|
||||
void OSystem_DS::setFocusRectangle(const Common::Rect& rect) {
|
||||
|
|
|
@ -53,6 +53,8 @@ public:
|
|||
DSAudioMixer* _mixer;
|
||||
DSTimerManager* _timer;
|
||||
|
||||
Graphics::Surface _framebuffer;
|
||||
|
||||
static OSystem_DS* _instance;
|
||||
|
||||
typedef void (*SoundProc)(void *param, byte *buf, int len);
|
||||
|
@ -127,7 +129,8 @@ public:
|
|||
void addEvent(Common::Event& e);
|
||||
bool isEventQueueEmpty() { return queuePos == 0; }
|
||||
|
||||
virtual bool grabRawScreen(Graphics::Surface* surf);
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
virtual void unlockScreen();
|
||||
|
||||
virtual void setFocusRectangle(const Common::Rect& rect);
|
||||
|
||||
|
|
|
@ -90,11 +90,8 @@ public:
|
|||
// The screen will not be updated to reflect the new bitmap
|
||||
void copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h);
|
||||
|
||||
// Copies the screen to a buffer
|
||||
bool grabRawScreen(Graphics::Surface *surf);
|
||||
|
||||
// Clear the screen
|
||||
void clearScreen();
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
virtual void unlockScreen();
|
||||
|
||||
// Update the dirty areas of the screen
|
||||
void updateScreen();
|
||||
|
|
|
@ -687,22 +687,6 @@ void OSystem_GP2X::setZoomOnMouse() {
|
|||
}
|
||||
}
|
||||
|
||||
void OSystem_GP2X::clearScreen() {
|
||||
assert (_transactionMode == kTransactionNone);
|
||||
|
||||
// Try to lock the screen surface
|
||||
if (SDL_LockSurface(_screen) == -1)
|
||||
error("SDL_LockSurface failed: %s", SDL_GetError());
|
||||
|
||||
byte *dst = (byte *)_screen->pixels;
|
||||
|
||||
// Clear the screen
|
||||
memset(dst, 0, _screenWidth * _screenHeight);
|
||||
|
||||
// Unlock the screen surface
|
||||
SDL_UnlockSurface(_screen);
|
||||
}
|
||||
|
||||
void OSystem_GP2X::copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h) {
|
||||
assert (_transactionMode == kTransactionNone);
|
||||
assert(src);
|
||||
|
@ -772,15 +756,19 @@ void OSystem_GP2X::copyRectToScreen(const byte *src, int pitch, int x, int y, in
|
|||
SDL_UnlockSurface(_screen);
|
||||
}
|
||||
|
||||
// TIDY: DIRTY HACK: Try a REALLY simple version of grabRawScreen to
|
||||
// debug why it will not work on the GP2X.
|
||||
bool OSystem_GP2X::grabRawScreen(Graphics::Surface *surf) {
|
||||
assert(surf);
|
||||
Graphics::Surface *OSystem_GP2X::lockScreen() {
|
||||
_framebuffer.pixels = _screen->pixels;
|
||||
_framebuffer.w = _screen->w;
|
||||
_framebuffer.h = _screen->h;
|
||||
_framebuffer.pitch = _screen->pitch;
|
||||
_framebuffer.bytesPerPixel = 1;
|
||||
|
||||
surf->create(_screenWidth, _screenHeight, 1);
|
||||
memcpy(surf->pixels, _screen->pixels, _screenWidth * _screenHeight);
|
||||
return &_framebuffer;
|
||||
}
|
||||
|
||||
return true;
|
||||
void OSystem_GP2X::unlockScreen() {
|
||||
// Force screen update
|
||||
_forceFull = true;
|
||||
}
|
||||
|
||||
void OSystem_GP2X::addDirtyRect(int x, int y, int w, int h, bool realCoordinates) {
|
||||
|
|
|
@ -209,14 +209,18 @@ void OSystem_GP32::copyRectToScreen(const byte *src, int pitch, int x, int y, in
|
|||
}
|
||||
}
|
||||
|
||||
bool OSystem_GP32::grabRawScreen(Graphics::Surface *surf) {
|
||||
assert(surf);
|
||||
Graphics::Surface *OSystem_GP32::lockScreen() {
|
||||
_framebuffer.pixels = _gameScreen;
|
||||
_framebuffer.w = _screenWidth;
|
||||
_framebuffer.h = _screenHeight;
|
||||
_framebuffer.pitch = _screenWidth;
|
||||
_framebuffer.bytesPerPixel = 1;
|
||||
|
||||
surf->create(_screenWidth, _screenHeight, 1);
|
||||
return &_framebuffer;
|
||||
}
|
||||
|
||||
memcpy(surf->pixels, _gameScreen, _screenWidth * _screenHeight);
|
||||
|
||||
return true;
|
||||
void OSystem_GP32::unlockScreen() {
|
||||
// The screen is always completely update anyway, so we don't have to force a full update here.
|
||||
}
|
||||
|
||||
//TODO: Implement Dirty rect?
|
||||
|
|
|
@ -49,6 +49,8 @@ protected:
|
|||
uint16 *_tmpScreen, *_hwScreen;
|
||||
OverlayColor *_overlayBuffer;
|
||||
|
||||
Graphics::Surface _framebuffer;
|
||||
|
||||
int _overlayWidth, _overlayHeight;
|
||||
bool _overlayVisible;
|
||||
uint32 _shakePos;
|
||||
|
@ -111,7 +113,8 @@ public:
|
|||
void grabOverlay(OverlayColor *buf, int pitch);
|
||||
void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h);
|
||||
|
||||
bool grabRawScreen(Graphics::Surface *surf);
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
virtual void unlockScreen();
|
||||
|
||||
int16 getOverlayHeight();
|
||||
int16 getOverlayWidth();
|
||||
|
|
|
@ -63,7 +63,8 @@ public:
|
|||
virtual void grabPalette(byte *colors, uint start, uint num);
|
||||
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
|
||||
virtual void updateScreen();
|
||||
virtual bool grabRawScreen(Graphics::Surface *surf);
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
virtual void unlockScreen();
|
||||
virtual void setShakePos(int shakeOffset);
|
||||
|
||||
virtual void showOverlay();
|
||||
|
@ -189,8 +190,11 @@ void OSystem_NULL::copyRectToScreen(const byte *buf, int pitch, int x, int y, in
|
|||
void OSystem_NULL::updateScreen() {
|
||||
}
|
||||
|
||||
bool OSystem_NULL::grabRawScreen(Graphics::Surface *surf) {
|
||||
return false;
|
||||
Graphics::Surface *OSystem_NULL::lockScreen() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void OSystem_NULL::unlockScreen() {
|
||||
}
|
||||
|
||||
void OSystem_NULL::setShakePos(int shakeOffset) {
|
||||
|
|
|
@ -364,13 +364,6 @@ void Gs2dScreen::copyScreenRect(const uint8 *buf, int pitch, int x, int y, int w
|
|||
}
|
||||
}
|
||||
|
||||
void Gs2dScreen::clearScreen(void) {
|
||||
WaitSema(g_DmacSema);
|
||||
memset(_screenBuf, 0, _width * _height);
|
||||
_screenChanged = true;
|
||||
SignalSema(g_DmacSema);
|
||||
}
|
||||
|
||||
void Gs2dScreen::setPalette(const uint32 *pal, uint8 start, uint16 num) {
|
||||
assert(start + num <= 256);
|
||||
|
||||
|
@ -393,11 +386,20 @@ void Gs2dScreen::grabPalette(uint32 *pal, uint8 start, uint16 num) {
|
|||
}
|
||||
}
|
||||
|
||||
void Gs2dScreen::grabScreen(Graphics::Surface *surf) {
|
||||
assert(surf);
|
||||
Graphics::Surface *Gs2dScreen::lockScreen() {
|
||||
WaitSema(g_DmacSema);
|
||||
surf->create(_width, _height, 1);
|
||||
memcpy(surf->pixels, _screenBuf, _width * _height);
|
||||
|
||||
_framebuffer.pixels = _screen->pixels;
|
||||
_framebuffer.w = _screen->w;
|
||||
_framebuffer.h = _screen->h;
|
||||
_framebuffer.pitch = _screen->pitch;
|
||||
_framebuffer.bytesPerPixel = 1;
|
||||
|
||||
return &_framebuffer;
|
||||
}
|
||||
|
||||
void Gs2dScreen::unlockScreen() {
|
||||
_screenChanged = true;
|
||||
SignalSema(g_DmacSema);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,13 +56,13 @@ public:
|
|||
|
||||
void copyPrintfOverlay(const uint8* buf);
|
||||
void clearPrintfOverlay(void);
|
||||
void clearScreen(void);
|
||||
|
||||
void copyScreenRect(const uint8 *buf, int pitch, int x, int y, int w, int h);
|
||||
void setPalette(const uint32 *pal, uint8 start, uint16 num);
|
||||
void updateScreen(void);
|
||||
void grabPalette(uint32 *pal, uint8 start, uint16 num);
|
||||
void grabScreen(Graphics::Surface *surf);
|
||||
Graphics::Surface *lockScreen();
|
||||
void unlockScreen();
|
||||
//- overlay routines
|
||||
void copyOverlayRect(const uint16 *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h);
|
||||
void grabOverlay(uint16 *buf, uint16 pitch);
|
||||
|
@ -99,6 +99,8 @@ private:
|
|||
uint32 _mouseScaleX, _mouseScaleY;
|
||||
uint8 _mTraCol;
|
||||
|
||||
Graphics::Surface _framebuffer;
|
||||
|
||||
int _shakePos;
|
||||
|
||||
bool _showMouse, _showOverlay, _screenChanged, _overlayChanged, _clutChanged;
|
||||
|
|
|
@ -326,7 +326,7 @@ OSystem_PS2::OSystem_PS2(const char *elfPath) {
|
|||
}
|
||||
|
||||
_screen->wantAnim(false);
|
||||
_screen->clearScreen();
|
||||
clearScreen();
|
||||
}
|
||||
|
||||
OSystem_PS2::~OSystem_PS2(void) {
|
||||
|
@ -510,9 +510,12 @@ void OSystem_PS2::copyRectToScreen(const byte *buf, int pitch, int x, int y, int
|
|||
_screen->copyScreenRect((const uint8*)buf, pitch, x, y, w, h);
|
||||
}
|
||||
|
||||
bool OSystem_PS2::grabRawScreen(Graphics::Surface *surf) {
|
||||
_screen->grabScreen(surf);
|
||||
return true;
|
||||
Graphics::Surface *OSystem_PS2::lockScreen() {
|
||||
return _screen->lockScreen();
|
||||
}
|
||||
|
||||
void OSystem_PS2::unlockScreen() {
|
||||
_screen->unlockScreen();
|
||||
}
|
||||
|
||||
void OSystem_PS2::updateScreen(void) {
|
||||
|
|
|
@ -56,7 +56,8 @@ public:
|
|||
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
|
||||
virtual void setShakePos(int shakeOffset);
|
||||
virtual void grabPalette(byte *colors, uint start, uint num);
|
||||
virtual bool grabRawScreen(Graphics::Surface *surf);
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
virtual void unlockScreen();
|
||||
virtual void updateScreen();
|
||||
|
||||
virtual void showOverlay();
|
||||
|
|
|
@ -209,13 +209,18 @@ void OSystem_PSP::copyRectToScreen(const byte *buf, int pitch, int x, int y, int
|
|||
}
|
||||
}
|
||||
|
||||
bool OSystem_PSP::grabRawScreen(Graphics::Surface *surf) {
|
||||
assert(surf);
|
||||
Graphics::Surface *OSystem_PSP::lockScreen() {
|
||||
_framebuffer.pixels = _offscreen;
|
||||
_framebuffer.w = _screenWidth;
|
||||
_framebuffer.h = _screenHeight;
|
||||
_framebuffer.pitch = _screenWidth;
|
||||
_framebuffer.bytesPerPixel = 1;
|
||||
|
||||
surf->create(_screenWidth, _screenHeight, 1);
|
||||
memcpy(surf->pixels, _offscreen, _screenWidth * _screenHeight);
|
||||
return &_framebuffer;
|
||||
}
|
||||
|
||||
return true;
|
||||
void OSystem_PSP::unlockScreen() {
|
||||
// The screen is always completely update anyway, so we don't have to force a full update here.
|
||||
}
|
||||
|
||||
void OSystem_PSP::updateScreen() {
|
||||
|
|
|
@ -62,6 +62,7 @@ protected:
|
|||
bool _overlayVisible;
|
||||
uint32 _shakePos;
|
||||
|
||||
Graphics::Surface _framebuffer;
|
||||
|
||||
bool _mouseVisible;
|
||||
int _mouseX, _mouseY;
|
||||
|
@ -101,7 +102,8 @@ public:
|
|||
virtual int16 getHeight();
|
||||
virtual void setPalette(const byte *colors, uint start, uint num);
|
||||
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
|
||||
virtual bool grabRawScreen(Graphics::Surface *surf);
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
virtual void unlockScreen();
|
||||
virtual void updateScreen();
|
||||
virtual void setShakePos(int shakeOffset);
|
||||
|
||||
|
|
|
@ -761,22 +761,6 @@ void OSystem_SDL::setAspectRatioCorrection(bool enable) {
|
|||
}
|
||||
}
|
||||
|
||||
void OSystem_SDL::clearScreen() {
|
||||
assert (_transactionMode == kTransactionNone);
|
||||
|
||||
// Try to lock the screen surface
|
||||
if (SDL_LockSurface(_screen) == -1)
|
||||
error("SDL_LockSurface failed: %s", SDL_GetError());
|
||||
|
||||
byte *dst = (byte *)_screen->pixels;
|
||||
|
||||
// Clear the screen
|
||||
memset(dst, 0, _screenWidth * _screenHeight);
|
||||
|
||||
// Unlock the screen surface
|
||||
SDL_UnlockSurface(_screen);
|
||||
}
|
||||
|
||||
void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h) {
|
||||
assert (_transactionMode == kTransactionNone);
|
||||
assert(src);
|
||||
|
@ -848,24 +832,44 @@ void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int
|
|||
SDL_UnlockSurface(_screen);
|
||||
}
|
||||
|
||||
bool OSystem_SDL::grabRawScreen(Graphics::Surface *surf) {
|
||||
assert(_screen);
|
||||
assert(surf);
|
||||
Graphics::Surface *OSystem_SDL::lockScreen() {
|
||||
assert (_transactionMode == kTransactionNone);
|
||||
|
||||
Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends
|
||||
// Lock the graphics mutex
|
||||
lockMutex(_graphicsMutex);
|
||||
|
||||
surf->create(_screenWidth, _screenHeight, _screen->format->BytesPerPixel);
|
||||
// paranoia check
|
||||
assert(!_screenIsLocked);
|
||||
_screenIsLocked = true;
|
||||
|
||||
// Try to lock the screen surface
|
||||
if (SDL_LockSurface(_screen) == -1)
|
||||
error("SDL_LockSurface failed: %s", SDL_GetError());
|
||||
|
||||
memcpy(surf->pixels, _screen->pixels, _screenWidth * _screenHeight * _screen->format->BytesPerPixel);
|
||||
_framebuffer.pixels = _screen->pixels;
|
||||
_framebuffer.w = _screen->w;
|
||||
_framebuffer.h = _screen->h;
|
||||
_framebuffer.pitch = _screen->pitch;
|
||||
_framebuffer.bytesPerPixel = 1;
|
||||
|
||||
return &_framebuffer;
|
||||
}
|
||||
|
||||
void OSystem_SDL::unlockScreen() {
|
||||
assert (_transactionMode == kTransactionNone);
|
||||
|
||||
// paranoia check
|
||||
assert(_screenIsLocked);
|
||||
_screenIsLocked = false;
|
||||
|
||||
// Unlock the screen surface
|
||||
SDL_UnlockSurface(_screen);
|
||||
|
||||
return true;
|
||||
// Trigger a full screen update
|
||||
_forceFull = true;
|
||||
|
||||
// Finally unlock the graphics mutex
|
||||
unlockMutex(_graphicsMutex);
|
||||
}
|
||||
|
||||
void OSystem_SDL::addDirtyRect(int x, int y, int w, int h, bool realCoordinates) {
|
||||
|
|
|
@ -92,11 +92,8 @@ public:
|
|||
// The screen will not be updated to reflect the new bitmap
|
||||
virtual void copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h); // overloaded by CE backend (FIXME)
|
||||
|
||||
// Copies the screen to a buffer
|
||||
bool grabRawScreen(Graphics::Surface *surf);
|
||||
|
||||
// Clear the screen
|
||||
void clearScreen();
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
virtual void unlockScreen();
|
||||
|
||||
// Update the dirty areas of the screen
|
||||
void updateScreen();
|
||||
|
@ -218,6 +215,8 @@ protected:
|
|||
|
||||
// unseen game screen
|
||||
SDL_Surface *_screen;
|
||||
|
||||
// TODO: We could get rid of the following two vars and just use _screen instead
|
||||
int _screenWidth, _screenHeight;
|
||||
|
||||
// temporary screen (for scalers)
|
||||
|
@ -275,6 +274,9 @@ protected:
|
|||
int _transactionMode;
|
||||
bool _fullscreen;
|
||||
|
||||
bool _screenIsLocked;
|
||||
Graphics::Surface _framebuffer;
|
||||
|
||||
/** Current video mode flags (see DF_* constants) */
|
||||
uint32 _modeFlags;
|
||||
bool _modeChanged;
|
||||
|
|
|
@ -243,6 +243,7 @@ OSystem_SDL::OSystem_SDL()
|
|||
_savefile(0),
|
||||
_mixer(0),
|
||||
_timer(0),
|
||||
_screenIsLocked(false),
|
||||
_graphicsMutex(0), _transactionMode(kTransactionNone) {
|
||||
|
||||
// allocate palette storage
|
||||
|
|
|
@ -1587,9 +1587,15 @@ void OSystem_WINCE3::internUpdateScreen() {
|
|||
_forceFull = false;
|
||||
}
|
||||
|
||||
bool OSystem_WINCE3::grabRawScreen(Graphics::Surface *surf) {
|
||||
Graphics::Surface *OSystem_WINCE3::lockScreen() {
|
||||
// FIXME: Fingolfing asks: Why is undrawMouse() needed here?
|
||||
// Please document this.
|
||||
undrawMouse();
|
||||
return OSystem_SDL::grabRawScreen(surf);
|
||||
return OSystem_SDL::lockScreen();
|
||||
}
|
||||
|
||||
void OSystem_WINCE3::unlockScreen() {
|
||||
OSystem_SDL::unlockScreen();
|
||||
}
|
||||
|
||||
bool OSystem_WINCE3::saveScreenshot(const char *filename) {
|
||||
|
|
|
@ -97,7 +97,8 @@ public:
|
|||
void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h);
|
||||
void showOverlay();
|
||||
void hideOverlay();
|
||||
bool grabRawScreen(Graphics::Surface *surf);
|
||||
Graphics::Surface *lockScreen();
|
||||
void unlockScreen();
|
||||
|
||||
// GUI and action stuff
|
||||
void swap_panel_visibility();
|
||||
|
|
|
@ -101,3 +101,8 @@ Common::EventManager *OSystem::getEventManager() {
|
|||
return s_eventManager;
|
||||
}
|
||||
|
||||
void OSystem::clearScreen() {
|
||||
Graphics::Surface *screen = lockScreen();
|
||||
memset(screen->pixels, 0, screen->h * screen->pitch);
|
||||
unlockScreen();
|
||||
}
|
||||
|
|
|
@ -452,21 +452,34 @@ public:
|
|||
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) = 0;
|
||||
|
||||
/**
|
||||
* Copies the current screen contents to a new surface, with the original
|
||||
* bit depth. This will allocate memory for the pixel data.
|
||||
* WARNING: surf->free() must be called by the user to avoid leaking.
|
||||
* Lock the active screen framebuffer and return a Graphics::Surface
|
||||
* representing it. The caller can then perform arbitrary graphics
|
||||
* transformations on the framebuffer (blitting, scrolling, etc.).
|
||||
* Must be followed by matching call to unlockScreen(). Calling code
|
||||
* should make sure to only lock the framebuffer for the briefest
|
||||
* periods of time possible, as the whole system is potentially stalled
|
||||
* while the lock is active.
|
||||
* Returns 0 if an error occurred. Otherwise an 8bit surface is returned.
|
||||
*
|
||||
* @param surf the surfce to store the data in it
|
||||
* @return true if all went well, false if an error occured
|
||||
* The returned surface must *not* be deleted by the client code.
|
||||
*/
|
||||
virtual bool grabRawScreen(Graphics::Surface *surf) = 0;
|
||||
virtual Graphics::Surface *lockScreen() = 0;
|
||||
|
||||
/**
|
||||
* Unlock the screen framebuffer, and mark it as dirty (i.e. during the
|
||||
* next updateScreen() call, the whole screen will be updated.
|
||||
*/
|
||||
virtual void unlockScreen() = 0;
|
||||
|
||||
/**
|
||||
* Clear the screen to black.
|
||||
*/
|
||||
virtual void clearScreen() {}
|
||||
virtual void clearScreen();
|
||||
|
||||
/** Update the dirty areas of the screen. */
|
||||
/**
|
||||
* Flush the whole screen, that is render the current content of the screen
|
||||
* framebuffer (resp. the dirty/changed parts of it) to the display.
|
||||
*/
|
||||
virtual void updateScreen() = 0;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1146,12 +1146,11 @@ void ScummEngine::moveScreen(int dx, int dy, int height) {
|
|||
if ((dx == 0 && dy == 0) || height <= 0)
|
||||
return;
|
||||
|
||||
Graphics::Surface screen;
|
||||
assert(_system->grabRawScreen(&screen));
|
||||
|
||||
screen.move(dx, dy, height);
|
||||
_system->copyRectToScreen((byte *)screen.pixels, screen.pitch, 0, 0, screen.w, screen.h);
|
||||
screen.free();
|
||||
Graphics::Surface *screen = _system->lockScreen();
|
||||
if (!screen)
|
||||
return;
|
||||
screen->move(dx, dy, height);
|
||||
_system->unlockScreen();
|
||||
}
|
||||
|
||||
void ScummEngine_v5::clearFlashlight() {
|
||||
|
|
|
@ -97,32 +97,32 @@ void createThumbnail(const uint8* src, uint32 srcPitch, uint8* dstPtr, uint32 ds
|
|||
* Copies the current screen contents to a new surface, using RGB565 format.
|
||||
* WARNING: surf->free() must be called by the user to avoid leaking.
|
||||
*
|
||||
* @param surf the surfce to store the data in it
|
||||
* @param surf the surface to store the data in it
|
||||
*/
|
||||
static bool grabScreen565(Graphics::Surface *surf) {
|
||||
Graphics::Surface screen;
|
||||
if (!g_system->grabRawScreen(&screen))
|
||||
Graphics::Surface *screen = g_system->lockScreen();
|
||||
if (!screen)
|
||||
return false;
|
||||
|
||||
assert(screen.bytesPerPixel == 1 && screen.pixels != 0);
|
||||
assert(screen->bytesPerPixel == 1 && screen->pixels != 0);
|
||||
|
||||
byte palette[256 * 4];
|
||||
g_system->grabPalette(&palette[0], 0, 256);
|
||||
|
||||
surf->create(screen.w, screen.h, 2);
|
||||
surf->create(screen->w, screen->h, 2);
|
||||
|
||||
for (uint y = 0; y < screen.h; ++y) {
|
||||
for (uint x = 0; x < screen.w; ++x) {
|
||||
for (uint y = 0; y < screen->h; ++y) {
|
||||
for (uint x = 0; x < screen->w; ++x) {
|
||||
byte r, g, b;
|
||||
r = palette[((uint8*)screen.pixels)[y * screen.pitch + x] * 4];
|
||||
g = palette[((uint8*)screen.pixels)[y * screen.pitch + x] * 4 + 1];
|
||||
b = palette[((uint8*)screen.pixels)[y * screen.pitch + x] * 4 + 2];
|
||||
r = palette[((uint8*)screen->pixels)[y * screen->pitch + x] * 4];
|
||||
g = palette[((uint8*)screen->pixels)[y * screen->pitch + x] * 4 + 1];
|
||||
b = palette[((uint8*)screen->pixels)[y * screen->pitch + x] * 4 + 2];
|
||||
|
||||
((uint16*)surf->pixels)[y * surf->w + x] = (((r >> 3) & 0x1F) << 11) | (((g >> 2) & 0x3F) << 5) | ((b >> 3) & 0x1F);
|
||||
}
|
||||
}
|
||||
|
||||
screen.free();
|
||||
g_system->unlockScreen();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue