aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/base/gfx
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-07-25 20:00:58 +0200
committerEinar Johan Trøan Sømåen2012-07-25 20:00:58 +0200
commit6e55e32a381d1219dfbe8d3c1532d55b28291192 (patch)
treebe0675bdbb14236502a154dbd1fea229c9ef4176 /engines/wintermute/base/gfx
parent6331bea4231b5db86d01a8f21b5ff84e4b96d8f6 (diff)
downloadscummvm-rg350-6e55e32a381d1219dfbe8d3c1532d55b28291192.tar.gz
scummvm-rg350-6e55e32a381d1219dfbe8d3c1532d55b28291192.tar.bz2
scummvm-rg350-6e55e32a381d1219dfbe8d3c1532d55b28291192.zip
WINTERMUTE: Cleanup and comment BaseRenderer a bit
Diffstat (limited to 'engines/wintermute/base/gfx')
-rw-r--r--engines/wintermute/base/gfx/base_image.cpp9
-rw-r--r--engines/wintermute/base/gfx/base_image.h8
-rw-r--r--engines/wintermute/base/gfx/base_renderer.cpp30
-rw-r--r--engines/wintermute/base/gfx/base_renderer.h70
-rw-r--r--engines/wintermute/base/gfx/osystem/base_render_osystem.cpp34
-rw-r--r--engines/wintermute/base/gfx/osystem/base_render_osystem.h9
6 files changed, 83 insertions, 77 deletions
diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp
index 2c18b64110..09a78a748b 100644
--- a/engines/wintermute/base/gfx/base_image.cpp
+++ b/engines/wintermute/base/gfx/base_image.cpp
@@ -92,7 +92,7 @@ bool BaseImage::loadFile(const Common::String &filename) {
return true;
}
-byte BaseImage::getAlphaAt(int x, int y) {
+byte BaseImage::getAlphaAt(int x, int y) const {
if (!_surface) return 0xFF;
uint32 color = *(uint32 *)_surface->getBasePtr(x, y);
byte r, g, b, a;
@@ -100,19 +100,20 @@ byte BaseImage::getAlphaAt(int x, int y) {
return a;
}
-void BaseImage::copyFrom(Graphics::Surface *surface) {
+void BaseImage::copyFrom(const Graphics::Surface *surface) {
_surface = _deletableSurface = new Graphics::Surface();
_deletableSurface->copyFrom(*surface);
}
//////////////////////////////////////////////////////////////////////////
-bool BaseImage::saveBMPFile(const char *filename) {
+bool BaseImage::saveBMPFile(const char *filename) const {
#if 0
if (!_bitmap) return STATUS_FAILED;
if (FreeImage_Save(FIF_BMP, _bitmap, filename)) return STATUS_OK;
else return STATUS_FAILED;
#endif
+ warning("BaseImage::saveBMPFile - stubbed"); // TODO
return false;
}
@@ -138,7 +139,7 @@ bool BaseImage::resize(int newWidth, int newHeight) {
//////////////////////////////////////////////////////////////////////////
-bool BaseImage::writeBMPToStream(Common::WriteStream *stream) {
+bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const {
if (!_surface) return false;
/* The following is just copied over and inverted to write-ops from the BMP-decoder */
diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h
index 7f344b5c1c..ed0142ea95 100644
--- a/engines/wintermute/base/gfx/base_image.h
+++ b/engines/wintermute/base/gfx/base_image.h
@@ -52,12 +52,12 @@ public:
const byte *getPalette() const {
return _palette;
}
- byte getAlphaAt(int x, int y);
- bool writeBMPToStream(Common::WriteStream *stream);
+ byte getAlphaAt(int x, int y) const;
+ bool writeBMPToStream(Common::WriteStream *stream) const;
bool resize(int newWidth, int newHeight);
- bool saveBMPFile(const char *filename);
+ bool saveBMPFile(const char *filename) const;
bool copyFrom(BaseImage *origImage, int newWidth = 0, int newHeight = 0);
- void copyFrom(Graphics::Surface *surface);
+ void copyFrom(const Graphics::Surface *surface);
private:
Common::String _filename;
Graphics::ImageDecoder *_decoder;
diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp
index ac475b3c5e..66b7f513bf 100644
--- a/engines/wintermute/base/gfx/base_renderer.cpp
+++ b/engines/wintermute/base/gfx/base_renderer.cpp
@@ -112,12 +112,6 @@ void BaseRenderer::deleteRectList() {
}
//////////////////////////////////////////////////////////////////////
-bool BaseRenderer::flip() {
- return STATUS_FAILED;
-}
-
-
-//////////////////////////////////////////////////////////////////////
bool BaseRenderer::initRenderer(int width, int height, bool windowed) {
return STATUS_FAILED;
}
@@ -128,12 +122,6 @@ void BaseRenderer::onWindowChange() {
}
-//////////////////////////////////////////////////////////////////////
-bool BaseRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) {
- return STATUS_FAILED;
-}
-
-
//////////////////////////////////////////////////////////////////////////
bool BaseRenderer::windowedBlt() {
return STATUS_FAILED;
@@ -171,18 +159,6 @@ bool BaseRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int wi
//////////////////////////////////////////////////////////////////////////
-bool BaseRenderer::fade(uint16 alpha) {
- return STATUS_FAILED;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-bool BaseRenderer::fadeToColor(uint32 color, Common::Rect *rect) {
- return STATUS_FAILED;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
bool BaseRenderer::setViewport(int left, int top, int right, int bottom) {
return STATUS_FAILED;
}
@@ -204,12 +180,6 @@ bool BaseRenderer::setViewport(Rect32 *rect) {
//////////////////////////////////////////////////////////////////////////
-BaseImage *BaseRenderer::takeScreenshot() {
- return NULL;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
bool BaseRenderer::clipCursor() {
/*
if (!_windowed) {
diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h
index b67f221e83..90a1e378ca 100644
--- a/engines/wintermute/base/gfx/base_renderer.h
+++ b/engines/wintermute/base/gfx/base_renderer.h
@@ -40,6 +40,12 @@ class BaseImage;
class BaseActiveRect;
class BaseObject;
class BaseSurface;
+
+/**
+ * @class BaseRenderer a common interface for the rendering portion of WME
+ * this interface is mainly intended to wrap away any differencies between
+ * software-rendering/hardware-rendering.
+ */
class BaseRenderer: public BaseClass {
public:
int _realWidth;
@@ -48,12 +54,34 @@ public:
int _drawOffsetY;
virtual void dumpData(const char *filename) {};
- virtual BaseImage *takeScreenshot();
+ /**
+ * Take a screenshot of the current screenstate
+ *
+ * @return a BaseImage containing the current screen-buffer.
+ */
+ virtual BaseImage *takeScreenshot() = 0;
virtual bool setViewport(int left, int top, int right, int bottom);
- virtual bool setViewport(Rect32 *Rect);
+ virtual bool setViewport(Rect32 *rect);
virtual bool setScreenViewport();
- virtual bool fade(uint16 Alpha);
- virtual bool fadeToColor(uint32 Color, Common::Rect *rect = NULL);
+
+ virtual Graphics::PixelFormat getPixelFormat() const = 0;
+ /**
+ * Fade the screen to black
+ *
+ * @param alpha amount to fade by (alpha value of black)
+ * @return
+ */
+ virtual void fade(uint16 alpha) = 0;
+ /**
+ * Fade a portion of the screen to a specific color
+ *
+ * @param r the red component to fade too.
+ * @param g the green component to fade too.
+ * @param b the blue component to fade too.
+ * @param a the alpha component to fade too.
+ * @param rect the portion of the screen to fade (if NULL, the entire screen will be faded).
+ */
+ virtual void fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect = NULL) = 0;
virtual bool drawLine(int x1, int y1, int x2, int y2, uint32 color);
virtual bool drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1);
BaseRenderer(BaseGame *inGame = NULL);
@@ -63,17 +91,33 @@ public:
};
virtual bool windowedBlt();
- virtual bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL);
+ /**
+ * Fill a portion of the screen with a specified color
+ *
+ * @param r the red component to fill with.
+ * @param g the green component to fill with.
+ * @param b the blue component to fill with.
+ */
+ virtual bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL) = 0;
virtual void onWindowChange();
virtual bool initRenderer(int width, int height, bool windowed);
- virtual bool flip();
+ /**
+ * Flip the backbuffer onto the screen-buffer
+ * The screen will NOT be updated before calling this function.
+ *
+ * @return true if successfull, false on error.
+ */
+ virtual bool flip() = 0;
virtual void initLoop();
virtual bool setup2D(bool force = false);
virtual bool setupLines();
- virtual const char *getName() {
- return "";
- };
+ /**
+ * Get the name of the current renderer
+ *
+ * @return the name of the renderer.
+ */
+ virtual Common::String getName() const = 0;
virtual bool displayDebugInfo() {
return STATUS_FAILED;
};
@@ -88,6 +132,14 @@ public:
return 1.0f;
}
+ /**
+ * Create a Surface fit for use with the renderer.
+ * As diverse implementations of BaseRenderer might have different solutions for storing surfaces
+ * this allows for a common interface for creating surface-handles. (Mostly usefull to ease future
+ * implementation of hw-accelerated rendering, or readding 3D-support at some point).
+ *
+ * @return a surface that can be used with this renderer
+ */
virtual BaseSurface *createSurface() = 0;
bool clipCursor();
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
index 2d2e62076c..09ee62c3b8 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
@@ -284,14 +284,14 @@ bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) {
}
//////////////////////////////////////////////////////////////////////////
-bool BaseRenderOSystem::fade(uint16 Alpha) {
- uint32 dwAlpha = 255 - Alpha;
- return fadeToColor(dwAlpha << 24);
+void BaseRenderOSystem::fade(uint16 alpha) {
+ byte dwAlpha = (byte)(255 - alpha);
+ return fadeToColor(0, 0, 0, dwAlpha);
}
//////////////////////////////////////////////////////////////////////////
-bool BaseRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) {
+void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect) {
// This particular warning is rather messy, as this function is called a ton,
// thus we avoid printing it more than once.
static bool hasWarned = false;
@@ -318,11 +318,6 @@ bool BaseRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) {
}
modTargetRect(&fillRect);
- byte r = RGBCOLGetR(Color);
- byte g = RGBCOLGetG(Color);
- byte b = RGBCOLGetB(Color);
- byte a = RGBCOLGetA(Color);
-
//TODO: This is only here until I'm sure about the final pixelformat
uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b);
if (_disableDirtyRects)
@@ -342,8 +337,10 @@ bool BaseRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) {
//SDL_SetRenderDrawColor(_renderer, r, g, b, a);
//SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND);
//SDL_RenderFillRect(_renderer, &fillRect);
+}
- return STATUS_OK;
+Graphics::PixelFormat BaseRenderOSystem::getPixelFormat() const {
+ return _renderSurface->format;
}
void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) {
@@ -589,17 +586,8 @@ BaseImage *BaseRenderOSystem::takeScreenshot() {
}
//////////////////////////////////////////////////////////////////////////
-const char *BaseRenderOSystem::getName() {
- if (_name.empty()) {
-#if 0
- if (_renderer) {
- SDL_RendererInfo info;
- SDL_GetRendererInfo(_renderer, &info);
- _name = AnsiString(info.name);
- }
-#endif
- }
- return _name.c_str();
+Common::String BaseRenderOSystem::getName() const {
+ return "ScummVM-OSystem-renderer";
}
//////////////////////////////////////////////////////////////////////////
@@ -611,10 +599,6 @@ bool BaseRenderOSystem::setViewport(int left, int top, int right, int bottom) {
rect.right = (int16)((right - left) * _ratioX);
rect.bottom = (int16)((bottom - top) * _ratioY);
- // TODO fix this once viewports work correctly in SDL/landscape
-#ifndef __IPHONEOS__
- //SDL_RenderSetViewport(GetSdlRenderer(), &rect);
-#endif
return STATUS_OK;
}
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h
index 3f4185dce2..b7507098da 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h
@@ -62,14 +62,14 @@ public:
BaseRenderOSystem(BaseGame *inGame);
~BaseRenderOSystem();
- const char *getName();
+ Common::String getName() const;
bool initRenderer(int width, int height, bool windowed);
bool flip();
bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL);
-
- bool fade(uint16 alpha);
- bool fadeToColor(uint32 color, Common::Rect *rect = NULL);
+ Graphics::PixelFormat getPixelFormat() const;
+ void fade(uint16 alpha);
+ void fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect = NULL);
bool drawLine(int x1, int y1, int x2, int y2, uint32 color);
@@ -109,7 +109,6 @@ private:
uint32 _drawNum;
Common::Rect _renderRect;
Graphics::Surface *_renderSurface;
- AnsiString _name;
int _borderLeft;
int _borderTop;