aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-08-13 02:09:09 +0200
committerEinar Johan Trøan Sømåen2012-08-13 02:09:09 +0200
commitbca8ce861ad3439881fef0f916b592aafc4ee010 (patch)
treecaaa3d79b0b47624ef48a48248b63f765a5e0628 /graphics
parentc1b5626bca1e0e08316353f1ead00ed763cd5380 (diff)
parentc839fd50b5ddfcceada8cbbd3046ce219df248a0 (diff)
downloadscummvm-rg350-bca8ce861ad3439881fef0f916b592aafc4ee010.tar.gz
scummvm-rg350-bca8ce861ad3439881fef0f916b592aafc4ee010.tar.bz2
scummvm-rg350-bca8ce861ad3439881fef0f916b592aafc4ee010.zip
Merge remote-tracking branch 'origin/master' into wintermute
Diffstat (limited to 'graphics')
-rw-r--r--graphics/VectorRendererSpec.cpp4
-rw-r--r--graphics/cursorman.cpp20
-rw-r--r--graphics/cursorman.h14
-rw-r--r--graphics/decoders/image_decoder.h3
-rw-r--r--graphics/fonts/ttf.cpp10
-rw-r--r--graphics/fonts/ttf.h2
-rw-r--r--graphics/iff.cpp23
-rw-r--r--graphics/pixelformat.h2
-rw-r--r--graphics/scaler.cpp9
-rw-r--r--graphics/scaler/aspect.cpp10
10 files changed, 49 insertions, 48 deletions
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index 7817725664..1ed5a3308a 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -422,8 +422,8 @@ void VectorRendererSpec<PixelType>::
copyFrame(OSystem *sys, const Common::Rect &r) {
sys->copyRectToOverlay(
- (const OverlayColor *)_activeSurface->getBasePtr(r.left, r.top),
- _activeSurface->pitch / _activeSurface->format.bytesPerPixel,
+ _activeSurface->getBasePtr(r.left, r.top),
+ _activeSurface->pitch,
r.left, r.top, r.width(), r.height()
);
}
diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp
index 425714ea34..c818101645 100644
--- a/graphics/cursorman.cpp
+++ b/graphics/cursorman.cpp
@@ -55,14 +55,14 @@ bool CursorManager::showMouse(bool visible) {
return g_system->showMouse(visible);
}
-void CursorManager::pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, const Graphics::PixelFormat *format) {
- Cursor *cur = new Cursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale, format);
+void CursorManager::pushCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) {
+ Cursor *cur = new Cursor(buf, w, h, hotspotX, hotspotY, keycolor, dontScale, format);
cur->_visible = isVisible();
_cursorStack.push(cur);
if (buf) {
- g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, format);
+ g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, dontScale, format);
}
}
@@ -75,7 +75,7 @@ void CursorManager::popCursor() {
if (!_cursorStack.empty()) {
cur = _cursorStack.top();
- g_system->setMouseCursor(cur->_data, cur->_width, cur->_height, cur->_hotspotX, cur->_hotspotY, cur->_keycolor, cur->_targetScale, &cur->_format);
+ g_system->setMouseCursor(cur->_data, cur->_width, cur->_height, cur->_hotspotX, cur->_hotspotY, cur->_keycolor, cur->_dontScale, &cur->_format);
}
g_system->showMouse(isVisible());
@@ -98,10 +98,10 @@ void CursorManager::popAllCursors() {
g_system->showMouse(isVisible());
}
-void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, const Graphics::PixelFormat *format) {
+void CursorManager::replaceCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) {
if (_cursorStack.empty()) {
- pushCursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale, format);
+ pushCursor(buf, w, h, hotspotX, hotspotY, keycolor, dontScale, format);
return;
}
@@ -131,7 +131,7 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX,
cur->_hotspotX = hotspotX;
cur->_hotspotY = hotspotY;
cur->_keycolor = keycolor;
- cur->_targetScale = targetScale;
+ cur->_dontScale = dontScale;
#ifdef USE_RGB_COLOR
if (format)
cur->_format = *format;
@@ -139,7 +139,7 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX,
cur->_format = Graphics::PixelFormat::createFormatCLUT8();
#endif
- g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, format);
+ g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, dontScale, format);
}
bool CursorManager::supportsCursorPalettes() {
@@ -225,7 +225,7 @@ void CursorManager::replaceCursorPalette(const byte *colors, uint start, uint nu
}
}
-CursorManager::Cursor::Cursor(const byte *data, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, const Graphics::PixelFormat *format) {
+CursorManager::Cursor::Cursor(const void *data, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) {
#ifdef USE_RGB_COLOR
if (!format)
_format = Graphics::PixelFormat::createFormatCLUT8();
@@ -245,7 +245,7 @@ CursorManager::Cursor::Cursor(const byte *data, uint w, uint h, int hotspotX, in
_height = h;
_hotspotX = hotspotX;
_hotspotY = hotspotY;
- _targetScale = targetScale;
+ _dontScale = dontScale;
}
CursorManager::Cursor::~Cursor() {
diff --git a/graphics/cursorman.h b/graphics/cursorman.h
index 543a5d0a5c..66e8d1ba56 100644
--- a/graphics/cursorman.h
+++ b/graphics/cursorman.h
@@ -63,14 +63,15 @@ public:
* @param hotspotY the hotspot Y coordinate
* @param keycolor the color value for the transparent color. This may not exceed
* the maximum color value as defined by format.
- * @param targetScale the scale for which the cursor is designed
+ * @param dontScale Whether the cursor should never be scaled. An exception are high ppi displays, where the cursor
+ * would be too small to notice otherwise, these are allowed to scale the cursor anyway.
* @param format a pointer to the pixel format which the cursor graphic uses,
* CLUT8 will be used if this is NULL or not specified.
* @note It is ok for the buffer to be a NULL pointer. It is sometimes
* useful to push a "dummy" cursor and modify it later. The
* cursor will be added to the stack, but not to the backend.
*/
- void pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale = 1, const Graphics::PixelFormat *format = NULL);
+ void pushCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL);
/**
* Pop a cursor from the stack, and restore the previous one to the
@@ -90,11 +91,12 @@ public:
* @param hotspotY the hotspot Y coordinate
* @param keycolor the color value for the transparent color. This may not exceed
* the maximum color value as defined by format.
- * @param targetScale the scale for which the cursor is designed
+ * @param dontScale Whether the cursor should never be scaled. An exception are high ppi displays, where the cursor
+ * would be too small to notice otherwise, these are allowed to scale the cursor anyway.
* @param format a pointer to the pixel format which the cursor graphic uses,
* CLUT8 will be used if this is NULL or not specified.
*/
- void replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale = 1, const Graphics::PixelFormat *format = NULL);
+ void replaceCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL);
/**
* Pop all of the cursors and cursor palettes from their respective stacks.
@@ -175,11 +177,11 @@ private:
int _hotspotY;
uint32 _keycolor;
Graphics::PixelFormat _format;
- int _targetScale;
+ bool _dontScale;
uint _size;
- Cursor(const byte *data, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale = 1, const Graphics::PixelFormat *format = NULL);
+ Cursor(const void *data, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL);
~Cursor();
};
diff --git a/graphics/decoders/image_decoder.h b/graphics/decoders/image_decoder.h
index 7fa00749ff..830645d361 100644
--- a/graphics/decoders/image_decoder.h
+++ b/graphics/decoders/image_decoder.h
@@ -75,6 +75,9 @@ public:
* until destroy() or loadStream() is called, or until this ImageDecoder's
* destructor is called.
*
+ * The palette's format is the same as PaletteManager's palette
+ * (interleaved RGB values).
+ *
* @return the decoded palette, or 0 if no palette is present
*/
virtual const byte *getPalette() const { return 0; }
diff --git a/graphics/fonts/ttf.cpp b/graphics/fonts/ttf.cpp
index 96241e923c..2b1dca1eae 100644
--- a/graphics/fonts/ttf.cpp
+++ b/graphics/fonts/ttf.cpp
@@ -101,7 +101,7 @@ public:
TTFFont();
virtual ~TTFFont();
- bool load(Common::SeekableReadStream &stream, int size, bool monochrome, const uint32 *mapping);
+ bool load(Common::SeekableReadStream &stream, int size, uint dpi, bool monochrome, const uint32 *mapping);
virtual int getFontHeight() const;
@@ -157,7 +157,7 @@ TTFFont::~TTFFont() {
}
}
-bool TTFFont::load(Common::SeekableReadStream &stream, int size, bool monochrome, const uint32 *mapping) {
+bool TTFFont::load(Common::SeekableReadStream &stream, int size, uint dpi, bool monochrome, const uint32 *mapping) {
if (!g_ttf.isInitialized())
return false;
@@ -195,7 +195,7 @@ bool TTFFont::load(Common::SeekableReadStream &stream, int size, bool monochrome
// Check whether we have kerning support
_hasKerning = (FT_HAS_KERNING(_face) != 0);
- if (FT_Set_Char_Size(_face, 0, size * 64, 0, 0)) {
+ if (FT_Set_Char_Size(_face, 0, size * 64, dpi, dpi)) {
delete[] _ttfFile;
_ttfFile = 0;
@@ -462,10 +462,10 @@ bool TTFFont::cacheGlyph(Glyph &glyph, FT_UInt &slot, uint chr) {
return true;
}
-Font *loadTTFFont(Common::SeekableReadStream &stream, int size, bool monochrome, const uint32 *mapping) {
+Font *loadTTFFont(Common::SeekableReadStream &stream, int size, uint dpi, bool monochrome, const uint32 *mapping) {
TTFFont *font = new TTFFont();
- if (!font->load(stream, size, monochrome, mapping)) {
+ if (!font->load(stream, size, dpi, monochrome, mapping)) {
delete font;
return 0;
}
diff --git a/graphics/fonts/ttf.h b/graphics/fonts/ttf.h
index ec7dbe04ef..e1464b1f45 100644
--- a/graphics/fonts/ttf.h
+++ b/graphics/fonts/ttf.h
@@ -32,7 +32,7 @@
namespace Graphics {
class Font;
-Font *loadTTFFont(Common::SeekableReadStream &stream, int size, bool monochrome = false, const uint32 *mapping = 0);
+Font *loadTTFFont(Common::SeekableReadStream &stream, int size, uint dpi = 0, bool monochrome = false, const uint32 *mapping = 0);
void shutdownTTF();
diff --git a/graphics/iff.cpp b/graphics/iff.cpp
index 7434a6bebc..4011126bd3 100644
--- a/graphics/iff.cpp
+++ b/graphics/iff.cpp
@@ -68,7 +68,7 @@ void ILBMDecoder::loadBitmap(uint32 mode, byte *buffer, Common::ReadStream *stre
Graphics::PackBitsReadStream packStream(*stream);
// setup a buffer to hold enough data to build a line in the output
- uint32 scanlineWidth = ((_header.width + 15)/16) << 1;
+ uint32 scanlineWidth = ((_header.width + 15) / 16) << 1;
byte *scanline = new byte[scanlineWidth * _header.depth];
for (uint i = 0; i < _header.height; ++i) {
@@ -82,7 +82,7 @@ void ILBMDecoder::loadBitmap(uint32 mode, byte *buffer, Common::ReadStream *stre
out += outPitch;
}
- delete []scanline;
+ delete[] scanline;
break;
}
@@ -121,15 +121,12 @@ void ILBMDecoder::planarToChunky(byte *out, uint32 outPitch, byte *in, uint32 in
// then output the pixel according to the requested packing
if (!packPlanes) {
out[x] = pix;
- } else
- if (nPlanes == 1) {
- out[x/8] |= (pix << (x & 7));
- } else
- if (nPlanes == 2) {
- out[x/4] |= (pix << ((x & 3) << 1));
- } else
- if (nPlanes == 4) {
- out[x/2] |= (pix << ((x & 1) << 2));
+ } else if (nPlanes == 1) {
+ out[x / 8] |= (pix << (x & 7));
+ } else if (nPlanes == 2) {
+ out[x / 4] |= (pix << ((x & 3) << 1));
+ } else if (nPlanes == 4) {
+ out[x / 2] |= (pix << ((x & 1) << 2));
}
}
@@ -187,7 +184,7 @@ struct PBMLoader {
_surface = &surface;
_colors = colors;
Common::IFFParser parser(&input);
- Common::Functor1Mem< Common::IFFChunk&, bool, PBMLoader > c(this, &PBMLoader::callback);
+ Common::Functor1Mem<Common::IFFChunk &, bool, PBMLoader> c(this, &PBMLoader::callback);
parser.parse(c);
}
@@ -251,7 +248,7 @@ uint32 PackBitsReadStream::read(void *dataPtr, uint32 dataSize) {
for (uint32 j = 0; j < lenW; j++) {
*out++ = _input->readByte();
}
- for ( ; lenR > lenW; lenR--) {
+ for (; lenR > lenW; lenR--) {
_input->readByte();
}
} else { // len > 128
diff --git a/graphics/pixelformat.h b/graphics/pixelformat.h
index e0cf6ce401..ca4ef11c17 100644
--- a/graphics/pixelformat.h
+++ b/graphics/pixelformat.h
@@ -97,7 +97,7 @@ struct PixelFormat {
}
inline void colorToARGB(uint32 color, uint8 &a, uint8 &r, uint8 &g, uint8 &b) const {
- a = ((color >> aShift) << aLoss) & 0xFF;
+ a = (aBits() == 0) ? 0xFF : (((color >> aShift) << aLoss) & 0xFF);
r = ((color >> rShift) << rLoss) & 0xFF;
g = ((color >> gShift) << gLoss) & 0xFF;
b = ((color >> bShift) << bLoss) & 0xFF;
diff --git a/graphics/scaler.cpp b/graphics/scaler.cpp
index 9ade0e6c57..b81e8937a8 100644
--- a/graphics/scaler.cpp
+++ b/graphics/scaler.cpp
@@ -167,12 +167,12 @@ void DestroyScalers(){
void Normal1x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
int width, int height) {
// Spot the case when it can all be done in 1 hit
- if ((srcPitch == sizeof(OverlayColor) * (uint)width) && (dstPitch == sizeof(OverlayColor) * (uint)width)) {
- memcpy(dstPtr, srcPtr, sizeof(OverlayColor) * width * height);
+ if ((srcPitch == sizeof(uint16) * (uint)width) && (dstPitch == sizeof(uint16) * (uint)width)) {
+ memcpy(dstPtr, srcPtr, sizeof(uint16) * width * height);
return;
}
while (height--) {
- memcpy(dstPtr, srcPtr, sizeof(OverlayColor) * width);
+ memcpy(dstPtr, srcPtr, sizeof(uint16) * width);
srcPtr += srcPitch;
dstPtr += dstPitch;
}
@@ -207,11 +207,10 @@ void Normal2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPit
uint8 *r;
assert(IS_ALIGNED(dstPtr, 4));
- assert(sizeof(OverlayColor) == 2);
while (height--) {
r = dstPtr;
for (int i = 0; i < width; ++i, r += 4) {
- uint32 color = *(((const OverlayColor *)srcPtr) + i);
+ uint32 color = *(((const uint16 *)srcPtr) + i);
color |= color << 16;
diff --git a/graphics/scaler/aspect.cpp b/graphics/scaler/aspect.cpp
index 7ad37b1ba8..f0ae732a40 100644
--- a/graphics/scaler/aspect.cpp
+++ b/graphics/scaler/aspect.cpp
@@ -160,14 +160,14 @@ int stretch200To240(uint8 *buf, uint32 pitch, int width, int height, int srcX, i
#if ASPECT_MODE == kSuperFastAndUglyAspectMode
if (srcPtr == dstPtr)
break;
- memcpy(dstPtr, srcPtr, sizeof(OverlayColor) * width);
+ memcpy(dstPtr, srcPtr, sizeof(uint16) * width);
#else
// Bilinear filter
switch (y % 6) {
case 0:
case 5:
if (srcPtr != dstPtr)
- memcpy(dstPtr, srcPtr, sizeof(OverlayColor) * width);
+ memcpy(dstPtr, srcPtr, sizeof(uint16) * width);
break;
case 1:
interpolate5Line<ColorMask, 1>((uint16 *)dstPtr, (const uint16 *)(srcPtr - pitch), (const uint16 *)srcPtr, width);
@@ -206,13 +206,13 @@ void Normal1xAspectTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr,
#if ASPECT_MODE == kSuperFastAndUglyAspectMode
if ((y % 6) == 5)
srcPtr -= srcPitch;
- memcpy(dstPtr, srcPtr, sizeof(OverlayColor) * width);
+ memcpy(dstPtr, srcPtr, sizeof(uint16) * width);
#else
// Bilinear filter five input lines onto six output lines
switch (y % 6) {
case 0:
// First output line is copied from first input line
- memcpy(dstPtr, srcPtr, sizeof(OverlayColor) * width);
+ memcpy(dstPtr, srcPtr, sizeof(uint16) * width);
break;
case 1:
// Second output line is mixed from first and second input line
@@ -233,7 +233,7 @@ void Normal1xAspectTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr,
case 5:
// Sixth (and last) output line is copied from fifth (and last) input line
srcPtr -= srcPitch;
- memcpy(dstPtr, srcPtr, sizeof(OverlayColor) * width);
+ memcpy(dstPtr, srcPtr, sizeof(uint16) * width);
break;
}
#endif