aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/samsungtv
diff options
context:
space:
mode:
authorPaweł Kołodziejski2009-11-14 15:46:38 +0000
committerPaweł Kołodziejski2009-11-14 15:46:38 +0000
commitace686aa3f0143aec0445a4dfe1a039cb80ac900 (patch)
treecc63f7f667fc97a7e936038cd173eba72a8246c7 /backends/platform/samsungtv
parent1de89723fd07183a07a29e0d26efddf174529b1f (diff)
downloadscummvm-rg350-ace686aa3f0143aec0445a4dfe1a039cb80ac900.tar.gz
scummvm-rg350-ace686aa3f0143aec0445a4dfe1a039cb80ac900.tar.bz2
scummvm-rg350-ace686aa3f0143aec0445a4dfe1a039cb80ac900.zip
samsungtv: continue reduction of code duplication
svn-id: r45900
Diffstat (limited to 'backends/platform/samsungtv')
-rw-r--r--backends/platform/samsungtv/graphics.cpp229
-rw-r--r--backends/platform/samsungtv/samsungtv.cpp2
-rw-r--r--backends/platform/samsungtv/samsungtv.h24
3 files changed, 18 insertions, 237 deletions
diff --git a/backends/platform/samsungtv/graphics.cpp b/backends/platform/samsungtv/graphics.cpp
index e97dea2451..a613e2b66a 100644
--- a/backends/platform/samsungtv/graphics.cpp
+++ b/backends/platform/samsungtv/graphics.cpp
@@ -34,220 +34,36 @@
#if defined(SAMSUNGTV)
-Common::List<Graphics::PixelFormat> OSystem_SDL_SamsungTV::getSupportedFormats() {
- static Common::List<Graphics::PixelFormat>list;
- SDL_Surface *bak = _hwscreen;
- _hwscreen = _prehwscreen;
- list = OSystem_SDL::getSupportedFormats();
- _hwscreen = bak;
- return list;
-}
-
-static void fixupResolutionForAspectRatio(AspectRatio desiredAspectRatio, int &width, int &height) {
- assert(&width != &height);
-
- // FIXME: TV SDL return empty list. However TV accept any resolution
- // Consider list fixed list or make calculation. For now it's disabled.
-// if (desiredAspectRatio.isAuto())
- return;
-
- int kw = desiredAspectRatio.kw();
- int kh = desiredAspectRatio.kh();
-
- const int w = width;
- const int h = height;
-
- SDL_Rect const* const*availableModes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_SWSURFACE); //TODO : Maybe specify a pixel format
- assert(availableModes);
-
- const SDL_Rect *bestMode = NULL;
- uint bestMetric = (uint)-1; // Metric is wasted space
- while (const SDL_Rect *mode = *availableModes++) {
- if (mode->w < w)
- continue;
- if (mode->h < h)
- continue;
- if (mode->h * kw != mode->w * kh)
- continue;
- //printf("%d %d\n", mode->w, mode->h);
-
- uint metric = mode->w * mode->h - w * h;
- if (metric > bestMetric)
- continue;
-
- bestMetric = metric;
- bestMode = mode;
- }
-
- if (!bestMode) {
- warning("Unable to enforce the desired aspect ratio!");
- return;
- }
- //printf("%d %d\n", bestMode->w, bestMode->h);
- width = bestMode->w;
- height = bestMode->h;
-}
-
bool OSystem_SDL_SamsungTV::loadGFXMode() {
- assert(_inited);
- _forceFull = true;
-
- _videoMode.overlayWidth = _videoMode.screenWidth * _videoMode.scaleFactor;
- _videoMode.overlayHeight = _videoMode.screenHeight * _videoMode.scaleFactor;
-
- if (_videoMode.screenHeight != 200 && _videoMode.screenHeight != 400)
- _videoMode.aspectRatioCorrection = false;
-
- if (_videoMode.aspectRatioCorrection)
- _videoMode.overlayHeight = real2Aspect(_videoMode.overlayHeight);
-
- _videoMode.hardwareWidth = _videoMode.screenWidth * _videoMode.scaleFactor;
- _videoMode.hardwareHeight = effectiveScreenHeight();
-
- _screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth, _videoMode.screenHeight,
- _screenFormat.bytesPerPixel << 3,
- ((1 << _screenFormat.rBits()) - 1) << _screenFormat.rShift ,
- ((1 << _screenFormat.gBits()) - 1) << _screenFormat.gShift ,
- ((1 << _screenFormat.bBits()) - 1) << _screenFormat.bShift ,
- ((1 << _screenFormat.aBits()) - 1) << _screenFormat.aShift );
- if (_screen == NULL)
- error("allocating _screen failed");
-
- //
- // Create the surface that contains the scaled graphics in 16 bit mode
- //
-
- if (_videoMode.fullscreen) {
- fixupResolutionForAspectRatio(_videoMode.desiredAspectRatio, _videoMode.hardwareWidth, _videoMode.hardwareHeight);
- }
-
- _prehwscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.hardwareWidth, _videoMode.hardwareHeight,
- 16, 0, 0, 0, 0);
- if (_prehwscreen == NULL)
- error("allocating _prehwscreen failed");
-
- _hwscreen = SDL_SetVideoMode(_videoMode.hardwareWidth, _videoMode.hardwareHeight, 32,
- _videoMode.fullscreen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
- );
-
- if (_hwscreen == NULL) {
- // DON'T use error(), as this tries to bring up the debug
- // console, which WON'T WORK now that _hwscreen is hosed.
+ OSystem_SDL::loadGFXMode();
+ _realhwscreen = SDL_SetVideoMode(_videoMode.hardwareWidth, _videoMode.hardwareHeight, 32,
+ _videoMode.fullscreen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE);
- if (!_oldVideoMode.setup) {
- warning("SDL_SetVideoMode says we can't switch to that mode (%s)", SDL_GetError());
- quit();
- } else {
- return false;
- }
- }
-
- //
- // Create the surface used for the graphics in 16 bit before scaling, and also the overlay
- //
-
- // Need some extra bytes around when using 2xSaI
- _tmpscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth + 3, _videoMode.screenHeight + 3,
- 16,
- _prehwscreen->format->Rmask,
- _prehwscreen->format->Gmask,
- _prehwscreen->format->Bmask,
- _prehwscreen->format->Amask);
-
- if (_tmpscreen == NULL)
- error("allocating _tmpscreen failed");
-
- _overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.overlayWidth, _videoMode.overlayHeight,
- 16,
- _prehwscreen->format->Rmask,
- _prehwscreen->format->Gmask,
- _prehwscreen->format->Bmask,
- _prehwscreen->format->Amask);
-
- if (_overlayscreen == NULL)
- error("allocating _overlayscreen failed");
-
- _overlayFormat.bytesPerPixel = _overlayscreen->format->BytesPerPixel;
-
- _overlayFormat.rLoss = _overlayscreen->format->Rloss;
- _overlayFormat.gLoss = _overlayscreen->format->Gloss;
- _overlayFormat.bLoss = _overlayscreen->format->Bloss;
- _overlayFormat.aLoss = _overlayscreen->format->Aloss;
-
- _overlayFormat.rShift = _overlayscreen->format->Rshift;
- _overlayFormat.gShift = _overlayscreen->format->Gshift;
- _overlayFormat.bShift = _overlayscreen->format->Bshift;
- _overlayFormat.aShift = _overlayscreen->format->Ashift;
-
- _tmpscreen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.overlayWidth + 3, _videoMode.overlayHeight + 3,
- 16,
- _prehwscreen->format->Rmask,
- _prehwscreen->format->Gmask,
- _prehwscreen->format->Bmask,
- _prehwscreen->format->Amask);
-
- if (_tmpscreen2 == NULL)
- error("allocating _tmpscreen2 failed");
-
-#ifdef USE_OSD
- _osdSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA,
- _hwscreen->w,
- _hwscreen->h,
- 32,
- _hwscreen->format->Rmask,
- _hwscreen->format->Gmask,
- _hwscreen->format->Bmask,
- _hwscreen->format->Amask);
- if (_osdSurface == NULL)
- error("allocating _osdSurface failed");
- SDL_SetColorKey(_osdSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, kOSDColorKey);
-#endif
-
- // keyboard cursor control, some other better place for it?
- _km.x_max = _videoMode.screenWidth * _videoMode.scaleFactor - 1;
- _km.y_max = effectiveScreenHeight() - 1;
- _km.delay_time = 25;
- _km.last_time = 0;
-
- // Distinguish 555 and 565 mode
- if (_screen->format->Rmask == 0x7C00)
- InitScalers(555);
- else
- InitScalers(565);
-
- return true;
+ return true;
}
void OSystem_SDL_SamsungTV::unloadGFXMode() {
- if (_prehwscreen) {
- SDL_FreeSurface(_prehwscreen);
- _prehwscreen = NULL;
- }
+ if (_realhwscreen) {
+ SDL_FreeSurface(_realhwscreen);
+ _realhwscreen = NULL;
+ }
- OSystem_SDL::unloadGFXMode();
+ OSystem_SDL::unloadGFXMode();
}
bool OSystem_SDL_SamsungTV::hotswapGFXMode() {
if (!_screen)
return false;
- SDL_FreeSurface(_prehwscreen); _prehwscreen = NULL;
+ SDL_FreeSurface(_realhwscreen); _realhwscreen = NULL;
return OSystem_SDL::hotswapGFXMode();
}
void OSystem_SDL_SamsungTV::internUpdateScreen() {
- // HACK: Use _prehwscreen instead of _hwscreen for this one.
- // On the long run, it would be cleaner to use _prehwscreen as _hwscreen,
- // and keep what is now called _hwscreen in a new variable _realhwscreen.
- // This way we wouldn't have to overload drawMouse(), too.
- SDL_Surface *bak = _hwscreen;
- _hwscreen = _prehwscreen;
OSystem_SDL::internUpdateScreen();
- _hwscreen = bak;
-
- SDL_BlitSurface(_prehwscreen, 0, _hwscreen, 0);
- SDL_UpdateRect(_hwscreen, 0, 0, 0, 0);
+ SDL_BlitSurface(_hwscreen, 0, _realhwscreen, 0);
+ SDL_UpdateRect(_realhwscreen, 0, 0, 0, 0);
}
void OSystem_SDL_SamsungTV::warpMouse(int x, int y) {
@@ -266,25 +82,4 @@ void OSystem_SDL_SamsungTV::warpMouse(int x, int y) {
}
}
-void OSystem_SDL_SamsungTV::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) {
- SDL_Surface *bak = _hwscreen;
- _hwscreen = _prehwscreen;
- OSystem_SDL::setMouseCursor(buf, w, h, hotspot_x, hotspot_y, keycolor, cursorTargetScale, format);
- _hwscreen = bak;
-}
-
-void OSystem_SDL_SamsungTV::blitCursor() {
- SDL_Surface *bak = _hwscreen;
- _hwscreen = _prehwscreen;
- OSystem_SDL::blitCursor();
- _hwscreen = bak;
-}
-
-void OSystem_SDL_SamsungTV::drawMouse() {
- SDL_Surface *bak = _hwscreen;
- _hwscreen = _prehwscreen;
- OSystem_SDL::drawMouse();
- _hwscreen = bak;
-}
-
#endif
diff --git a/backends/platform/samsungtv/samsungtv.cpp b/backends/platform/samsungtv/samsungtv.cpp
index 55e7952a1e..4bef9a2ec2 100644
--- a/backends/platform/samsungtv/samsungtv.cpp
+++ b/backends/platform/samsungtv/samsungtv.cpp
@@ -28,7 +28,7 @@
#if defined(SAMSUNGTV)
OSystem_SDL_SamsungTV::OSystem_SDL_SamsungTV() : OSystem_SDL(),
- _prehwscreen(0) {
+ _realhwscreen(0) {
}
bool OSystem_SDL_SamsungTV::hasFeature(Feature f) {
diff --git a/backends/platform/samsungtv/samsungtv.h b/backends/platform/samsungtv/samsungtv.h
index ac8a938315..8ef1e927e9 100644
--- a/backends/platform/samsungtv/samsungtv.h
+++ b/backends/platform/samsungtv/samsungtv.h
@@ -41,19 +41,8 @@ class OSystem_SDL_SamsungTV : public OSystem_SDL {
public:
OSystem_SDL_SamsungTV();
- // Highest supported
- virtual Common::List<Graphics::PixelFormat> getSupportedFormats();
-
- // Warp the mouse cursor. Where set_mouse_pos() only informs the
- // backend of the mouse cursor's current position, this function
- // actually moves the cursor to the specified position.
virtual void warpMouse(int x, int y);
- // Set the bitmap that's used when drawing the cursor.
- virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); // overloaded by CE backend (FIXME)
-
- // Get the next event.
- // Returns true if an event was retrieved.
virtual bool pollEvent(Common::Event &event);
virtual bool hasFeature(Feature f);
@@ -62,16 +51,13 @@ public:
protected:
- SDL_Surface *_prehwscreen;
-
- virtual void drawMouse(); // overloaded by CE backend
- virtual void blitCursor(); // overloaded by CE backend (FIXME)
+ SDL_Surface *_realhwscreen;
- virtual void internUpdateScreen(); // overloaded by CE backend
+ virtual void internUpdateScreen();
- virtual bool loadGFXMode(); // overloaded by CE backend
- virtual void unloadGFXMode(); // overloaded by CE backend
- virtual bool hotswapGFXMode(); // overloaded by CE backend
+ virtual bool loadGFXMode();
+ virtual void unloadGFXMode();
+ virtual bool hotswapGFXMode();
void handleKbdMouse();
void generateMouseMoveEvent(int x, int y);