aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/engine/kgraphics32.cpp6
-rw-r--r--engines/sci/graphics/helpers.h6
-rw-r--r--engines/sci/graphics/text32.cpp13
-rw-r--r--engines/sci/graphics/text32.h11
4 files changed, 21 insertions, 15 deletions
diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp
index 4083414724..b60607387b 100644
--- a/engines/sci/engine/kgraphics32.cpp
+++ b/engines/sci/engine/kgraphics32.cpp
@@ -619,9 +619,8 @@ reg_t kBitmapDrawText(EngineState *s, int argc, reg_t *argv) {
textRect.clip(Common::Rect(bitmap.getWidth(), bitmap.getHeight()));
reg_t textBitmapObject = g_sci->_gfxText32->createFontBitmap(textRect.width(), textRect.height(), Common::Rect(textRect.width(), textRect.height()), text, foreColor, backColor, skipColor, fontId, alignment, borderColor, dimmed, false);
- Buffer bitmapBuffer(bitmap.getWidth(), bitmap.getHeight(), bitmap.getPixels());
CelObjMem textCel(textBitmapObject);
- textCel.draw(bitmapBuffer, textRect, Common::Point(textRect.left, textRect.top), false);
+ textCel.draw(bitmap.getBuffer(), textRect, Common::Point(textRect.left, textRect.top), false);
s->_segMan->freeHunkEntry(textBitmapObject);
return s->r_acc;
@@ -638,8 +637,7 @@ reg_t kBitmapDrawColor(EngineState *s, int argc, reg_t *argv) {
argv[4].toSint16() + 1
);
- Buffer buffer(bitmap.getWidth(), bitmap.getHeight(), bitmap.getPixels());
- buffer.fillRect(fillRect, argv[5].toSint16());
+ bitmap.getBuffer().fillRect(fillRect, argv[5].toSint16());
return s->r_acc;
}
diff --git a/engines/sci/graphics/helpers.h b/engines/sci/graphics/helpers.h
index 19dddd74b8..32e7140d9b 100644
--- a/engines/sci/graphics/helpers.h
+++ b/engines/sci/graphics/helpers.h
@@ -191,6 +191,12 @@ struct Buffer : public Graphics::Surface {
uint16 scriptWidth;
uint16 scriptHeight;
+ Buffer() :
+ screenWidth(0),
+ screenHeight(0),
+ scriptWidth(320),
+ scriptHeight(200) {}
+
Buffer(const uint16 width, const uint16 height, uint8 *const pix) :
screenWidth(width),
screenHeight(height),
diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp
index 993c5c90ca..277e6e93d0 100644
--- a/engines/sci/graphics/text32.cpp
+++ b/engines/sci/graphics/text32.cpp
@@ -137,7 +137,6 @@ reg_t GfxText32::createFontBitmap(const CelInfo32 &celInfo, const Common::Rect &
BitmapResource bitmap(_segMan, _width, _height, _skipColor, 0, 0, _scaledWidth, _scaledHeight, 0, false);
_bitmap = bitmap.getObject();
- Buffer buffer(_width, _height, bitmap.getPixels());
// NOTE: The engine filled the bitmap pixels with 11 here, which is silly
// because then it just erased the bitmap using the skip color. So we don't
@@ -147,7 +146,7 @@ reg_t GfxText32::createFontBitmap(const CelInfo32 &celInfo, const Common::Rect &
erase(bitmapRect, false);
_backColor = backColor;
- view.draw(buffer, bitmapRect, Common::Point(0, 0), false, Ratio(_scaledWidth, view._scaledWidth), Ratio(_scaledHeight, view._scaledHeight));
+ view.draw(bitmap.getBuffer(), bitmapRect, Common::Point(0, 0), false, Ratio(_scaledWidth, view._scaledWidth), Ratio(_scaledHeight, view._scaledHeight));
if (_backColor != skipColor && _foreColor != skipColor) {
erase(_textRect, false);
@@ -616,14 +615,8 @@ Common::Rect GfxText32::getTextSize(const Common::String &text, int16 maxWidth,
void GfxText32::erase(const Common::Rect &rect, const bool doScaling) {
Common::Rect targetRect = doScaling ? scaleRect(rect) : rect;
- byte *bitmap = _segMan->getHunkPointer(_bitmap);
- byte *pixels = bitmap + READ_SCI11ENDIAN_UINT32(bitmap + 28);
-
- // NOTE: There is an extra optimisation within the SCI code to
- // do a single memset if the scaledRect is the same size as
- // the bitmap, not implemented here.
- Buffer buffer(_width, _height, pixels);
- buffer.fillRect(targetRect, _backColor);
+ BitmapResource bitmap(_bitmap);
+ bitmap.getBuffer().fillRect(targetRect, _backColor);
}
int16 GfxText32::getStringWidth(const Common::String &text) {
diff --git a/engines/sci/graphics/text32.h b/engines/sci/graphics/text32.h
index 9892740c42..a61760dd87 100644
--- a/engines/sci/graphics/text32.h
+++ b/engines/sci/graphics/text32.h
@@ -26,6 +26,7 @@
#include "sci/engine/state.h"
#include "sci/graphics/celobj32.h"
#include "sci/graphics/frameout.h"
+#include "sci/graphics/helpers.h"
namespace Sci {
@@ -60,6 +61,7 @@ inline void set##property(uint##size value) {\
class BitmapResource {
byte *_bitmap;
reg_t _object;
+ Buffer _buffer;
/**
* Gets the size of the bitmap header for the current
@@ -103,6 +105,8 @@ public:
if (_bitmap == nullptr || getUncompressedDataOffset() != getBitmapHeaderSize()) {
error("Invalid Text bitmap %04x:%04x", PRINT_REG(bitmap));
}
+
+ _buffer = Buffer(getWidth(), getHeight(), getPixels());
}
/**
@@ -110,7 +114,6 @@ public:
* segment manager.
*/
inline BitmapResource(SegManager *segMan, const int16 width, const int16 height, const uint8 skipColor, const int16 displaceX, const int16 displaceY, const int16 scaledWidth, const int16 scaledHeight, const uint32 hunkPaletteOffset, const bool remap) {
-
_object = segMan->allocateHunkEntry("Bitmap()", getBitmapSize(width, height));
_bitmap = segMan->getHunkPointer(_object);
@@ -131,12 +134,18 @@ public:
setControlOffset(0);
setScaledWidth(scaledWidth);
setScaledHeight(scaledHeight);
+
+ _buffer = Buffer(getWidth(), getHeight(), getPixels());
}
inline reg_t getObject() const {
return _object;
}
+ inline Buffer &getBuffer() {
+ return _buffer;
+ }
+
BITMAP_PROPERTY(16, Width, 0);
BITMAP_PROPERTY(16, Height, 2);