aboutsummaryrefslogtreecommitdiff
path: root/common/system.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/system.h')
-rw-r--r--common/system.h91
1 files changed, 88 insertions, 3 deletions
diff --git a/common/system.h b/common/system.h
index 5b3c208661..6f3dc6b6c8 100644
--- a/common/system.h
+++ b/common/system.h
@@ -31,6 +31,9 @@
#include "common/rect.h"
#include "graphics/pixelformat.h"
+#ifdef ENABLE_RGB_COLOR
+#include "graphics/conversion.h"
+#endif
namespace Audio {
class Mixer;
@@ -347,8 +350,50 @@ public:
*/
virtual int getGraphicsMode() const = 0;
+#ifdef ENABLE_RGB_COLOR
+ /**
+ * Determine the pixel format currently in use for screen rendering.
+ * @return the active screen pixel format.
+ * @see Graphics::PixelFormat
+ */
+ virtual Graphics::PixelFormat getScreenFormat() const = 0;
+
+ /**
+ * Returns a list of all pixel formats supported by the backend.
+ * The first item in the list must be directly supported by hardware,
+ * and provide the largest color space of those formats with direct
+ * hardware support. It is also strongly recommended that remaining
+ * formats should be placed in order of descending preference for the
+ * backend to use.
+ *
+ * EG: a backend that supports 32-bit ABGR and 16-bit 555 BGR in hardware
+ * and provides conversion from equivalent RGB(A) modes should order its list
+ * 1) Graphics::PixelFormat::createFormatABGR8888()
+ * 2) Graphics::PixelFormat::createFormatBGR555()
+ * 3) Graphics::PixelFormat::createFormatRGBA8888()
+ * 4) Graphics::PixelFormat::createFormatRGB555()
+ * 5) Graphics::PixelFormat::createFormatCLUT8()
+ *
+ * @see Graphics::PixelFormat
+ *
+ * @note All backends supporting RGB color must be able to accept game data
+ * in RGB color order, even if hardware uses BGR or some other color order.
+ */
+ virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const = 0;
+#else
+ inline Graphics::PixelFormat getScreenFormat() const {
+ return Graphics::PixelFormat::createFormatCLUT8();
+ };
+
+ inline Common::List<Graphics::PixelFormat> getSupportedFormats() const {
+ Common::List<Graphics::PixelFormat> list;
+ list.push_back(Graphics::PixelFormat::createFormatCLUT8());
+ return list;
+ };
+#endif
+
/**
- * Set the size of the virtual screen. Typical sizes include:
+ * Set the size and color format of the virtual screen. Typical sizes include:
* - 320x200 (e.g. for most SCUMM games, and Simon)
* - 320x240 (e.g. for FM-TOWN SCUMM games)
* - 640x480 (e.g. for Curse of Monkey Island)
@@ -359,10 +404,21 @@ public:
* GraphicsMode); stretch the data to perform aspect ratio correction;
* or shrink it to fit on small screens (in cell phones).
*
+ * Typical formats include:
+ * CLUT8 (e.g. 256 color, for most games)
+ * RGB555 (e.g. 16-bit color, for later SCUMM HE games)
+ * RGB565 (e.g. 16-bit color, for Urban Runner)
+ *
+ * This is the pixel format for which the client code generates data;
+ * this is not necessarily equal to the hardware pixel format. For example,
+ * a backend may perform color lookup of 8-bit graphics before pushing
+ * a screen to hardware, or correct the ARGB color order.
+ *
* @param width the new virtual screen width
* @param height the new virtual screen height
+ * @param format the new virtual screen pixel format
*/
- virtual void initSize(uint width, uint height) = 0;
+ virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format = NULL) = 0;
/**
* Return an int value which is changed whenever any screen
@@ -411,6 +467,9 @@ public:
kTransactionAspectRatioFailed = (1 << 0), /**< Failed switchting aspect ratio correction mode */
kTransactionFullscreenFailed = (1 << 1), /**< Failed switchting fullscreen mode */
kTransactionModeSwitchFailed = (1 << 2), /**< Failed switchting the GFX graphics mode (setGraphicsMode) */
+#ifdef ENABLE_RGB_COLOR
+ kTransactionFormatNotSupported = (1 << 4), /**< Failed setting the color format (function not yet implemented) */
+#endif
kTransactionSizeChangeFailed = (1 << 3) /**< Failed switchting the screen dimensions (initSize) */
};
@@ -705,8 +764,9 @@ public:
* @param hotspotY vertical offset from the top side to the hotspot
* @param keycolor transparency color index
* @param cursorTargetScale scale factor which cursor is designed for
+ * @param format pointer to the pixel format which cursor graphic uses
*/
- virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int cursorTargetScale = 1) = 0;
+ virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL) = 0;
/**
* Replace the specified range of cursor the palette with new colors.
@@ -962,6 +1022,31 @@ public:
*/
virtual Common::WriteStream *createConfigWriteStream() = 0;
+#ifdef ENABLE_RGB_COLOR
+private:
+ /**
+ * Convert a rectangle from the screen format to the hardware format.
+ *
+ * @param dstbuf the buffer which will recieve the converted graphics data
+ * @param srcbuf the buffer containing the original graphics data
+ * @param dstpitch width in bytes of one full line of the dest buffer
+ * @param srcpitch width in bytes of one full line of the source buffer
+ * @param w the width of the graphics data
+ * @param h the height of the graphics data
+ * @param hwFmt the pixel format currently set in hardware
+ * @return true if conversion completes successfully,
+ * false if there is an error.
+ *
+ * @note This implementation is slow. Please override this if
+ * your backend hardware has a better way to deal with this.
+ * @note This implementation requires the screen pixel format and
+ * the hardware pixel format to have a matching bytedepth
+ */
+ virtual bool convertScreenRect(byte *dstbuf, const byte *srcbuf, int dstpitch, int srcpitch,
+ int w, int h, Graphics::PixelFormat hwFmt) {
+ return Graphics::crossBlit(dstbuf,srcbuf,dstpitch,srcpitch,w,h,hwFmt,getScreenFormat());
+ };
+#endif // ENABLE_RGB_COLOR
//@}
};