[Scummvm-git-logs] scummvm master -> af37825be3522058015e3098a338e63c5c1c5182
aquadran
noreply at scummvm.org
Sat Nov 27 19:14:52 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
af37825be3 ENGINES: Replace PixelBuffer with Surface
Commit: af37825be3522058015e3098a338e63c5c1c5182
https://github.com/scummvm/scummvm/commit/af37825be3522058015e3098a338e63c5c1c5182
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2021-11-27T20:14:44+01:00
Commit Message:
ENGINES: Replace PixelBuffer with Surface
Changed paths:
engines/grim/bitmap.cpp
engines/grim/bitmap.h
engines/grim/emi/emi.cpp
engines/grim/emi/lua_v2.cpp
engines/grim/gfx_base.cpp
engines/grim/gfx_base.h
engines/grim/gfx_opengl.cpp
engines/grim/gfx_opengl.h
engines/grim/gfx_opengl_shaders.cpp
engines/grim/gfx_tinygl.cpp
engines/grim/gfx_tinygl.h
engines/grim/grim.cpp
engines/grim/lua_v1.cpp
engines/icb/icb.cpp
engines/icb/surface_manager.cpp
engines/icb/surface_manager.h
engines/myst3/gfx_tinygl.cpp
engines/stark/gfx/opengl.cpp
engines/stark/gfx/opengls.cpp
engines/stark/gfx/tinygl.cpp
graphics/tinygl/zbuffer.h
diff --git a/engines/grim/bitmap.cpp b/engines/grim/bitmap.cpp
index fff26378e7..1eb3ca8db1 100644
--- a/engines/grim/bitmap.cpp
+++ b/engines/grim/bitmap.cpp
@@ -22,7 +22,6 @@
#include "common/endian.h"
-#include "graphics/pixelbuffer.h"
#include "image/tga.h"
#include "engines/grim/savegame.h"
@@ -137,19 +136,19 @@ bool BitmapData::loadGrimBm(Common::SeekableReadStream *data) {
_colorFormat = BM_RGB565;
_hasTransparency = false;
- _data = new Graphics::PixelBuffer[_numImages];
+ _data = new Graphics::Surface[_numImages];
data->seek(0x80, SEEK_SET);
for (int i = 0; i < _numImages; i++) {
data->seek(8, SEEK_CUR);
- _data[i].create(pixelFormat, _width * _height, DisposeAfterUse::YES);
+ _data[i].create(_width, _height, pixelFormat);
if (codec == 0) {
uint32 dsize = _bpp / 8 * _width * _height;
- data->read(_data[i].getRawBuffer(), dsize);
+ data->read(_data[i].getPixels(), dsize);
} else if (codec == 3) {
int compressed_len = data->readUint32LE();
char *compressed = new char[compressed_len];
data->read(compressed, compressed_len);
- bool success = decompress_codec3(compressed, (char *)_data[i].getRawBuffer(), _bpp / 8 * _width * _height);
+ bool success = decompress_codec3(compressed, (char *)_data[i].getPixels(), _bpp / 8 * _width * _height);
delete[] compressed;
if (!success)
warning(".. when loading image %s.", _fname.c_str());
@@ -158,7 +157,7 @@ bool BitmapData::loadGrimBm(Common::SeekableReadStream *data) {
#ifdef SCUMM_BIG_ENDIAN
if (_format == 1) {
- uint16 *d = (uint16 *)_data[i].getRawBuffer();
+ uint16 *d = (uint16 *)_data[i].getPixels();
for (int j = 0; j < _width * _height; ++j) {
d[j] = SWAP_BYTES_16(d[j]);
}
@@ -175,7 +174,7 @@ bool BitmapData::loadGrimBm(Common::SeekableReadStream *data) {
return true;
}
-BitmapData::BitmapData(const Graphics::PixelBuffer &buf, int w, int h, const char *fname) : _fname(fname) {
+BitmapData::BitmapData(const Graphics::Surface &buf, int w, int h, const char *fname) : _fname(fname) {
_refCount = 1;
Debug::debug(Debug::Bitmaps, "New bitmap loaded: %s\n", fname);
_numImages = 1;
@@ -186,12 +185,11 @@ BitmapData::BitmapData(const Graphics::PixelBuffer &buf, int w, int h, const cha
_format = 1;
_numTex = 0;
_texIds = nullptr;
- _bpp = buf.getFormat().bytesPerPixel * 8;
+ _bpp = buf.format.bytesPerPixel * 8;
_hasTransparency = false;
_colorFormat = BM_RGB565;
- _data = new Graphics::PixelBuffer[_numImages];
- _data[0].create(buf.getFormat(), w * h, DisposeAfterUse::YES);
- _data[0].copyBuffer(0, w * h, buf);
+ _data = new Graphics::Surface[_numImages];
+ _data[0].copyFrom(buf);
_loaded = true;
_keepData = true;
@@ -258,8 +256,8 @@ bool BitmapData::loadTGA(Common::SeekableReadStream *data) {
_bpp = 4;
_colorFormat = BM_RGBA;
_numImages = 1;
- _data = new Graphics::PixelBuffer[1];
- _data[0].set(pixelFormat, (unsigned char *)surf->getPixels());
+ _data = new Graphics::Surface[1];
+ _data[0].init(surf->w, surf->h, surf->pitch, surf->getPixels(), surf->format);
g_driver->createBitmap(this);
@@ -305,9 +303,7 @@ bool BitmapData::loadTile(Common::SeekableReadStream *o) {
}
o->seek(16, SEEK_CUR);
- int numSubImages = o->readUint32LE();
-
- char **data = new char *[numSubImages];
+ _numImages = o->readUint32LE();
o->seek(16, SEEK_CUR);
_bpp = o->readUint32LE();
@@ -318,12 +314,16 @@ bool BitmapData::loadTile(Common::SeekableReadStream *o) {
_height = o->readUint32LE();
o->seek(-8, SEEK_CUR);
- int size = 4 * _width * _height;
- for (int i = 0; i < numSubImages; ++i) {
- data[i] = new char[size];
+ _data = new Graphics::Surface[_numImages];
+ Graphics::PixelFormat pixelFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
+ int width = 256;
+ int height = 256;
+
+ for (int i = 0; i < _numImages; ++i) {
+ _data[i].create(width, height, pixelFormat);
o->seek(8, SEEK_CUR);
if (_bpp == 16) {
- uint32 *d = (uint32 *)data[i];
+ uint32 *d = (uint32 *)_data[i].getPixels();
for (int j = 0; j < _width * _height; ++j) {
uint16 p = o->readUint16LE();
// These values are shifted left by 3 so that they saturate the color channel
@@ -336,34 +336,24 @@ bool BitmapData::loadTile(Common::SeekableReadStream *o) {
WRITE_BE_UINT32(&d[j], tmp);
}
} else if (_bpp == 32) {
- uint32 *d = (uint32 *)data[i];
+ uint32 *d = (uint32 *)_data[i].getPixels();
for (int j = 0; j < _width * _height; ++j) {
o->read(&(d[j]), 4);
}
}
}
- _bpp = 32;
- Graphics::PixelFormat pixelFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
+ _bpp = 32;
_colorFormat = BM_RGBA;
-
- _width = 256;
- _height = 256;
- _numImages = numSubImages;
- _data = new Graphics::PixelBuffer[_numImages];
- for (int i = 0; i < _numImages; ++i) {
- _data[i].create(pixelFormat, _width * _height, DisposeAfterUse::YES);
- _data[i].set(pixelFormat, (byte *)data[i]);
- }
-
- delete[] data;
+ _width = width;
+ _height = height;
g_driver->createBitmap(this);
#endif // ENABLE_MONKEY4
return true;
}
-const Graphics::PixelBuffer &BitmapData::getImageData(int num) const {
+const Graphics::Surface &BitmapData::getImageData(int num) const {
assert(num >= 0);
assert(num < _numImages);
return _data[num];
@@ -376,7 +366,7 @@ Bitmap::Bitmap(const Common::String &fname) {
_currImage = 1;
}
-Bitmap::Bitmap(const Graphics::PixelBuffer &buf, int w, int h, const char *fname) {
+Bitmap::Bitmap(const Graphics::Surface &buf, int w, int h, const char *fname) {
_data = new BitmapData(buf, w, h, fname);
_currImage = 1;
}
@@ -467,18 +457,14 @@ Bitmap::~Bitmap() {
}
const Graphics::PixelFormat &Bitmap::getPixelFormat(int num) const {
- return getData(num).getFormat();
+ return getData(num).format;
}
void BitmapData::convertToColorFormat(int num, const Graphics::PixelFormat &format) {
- if (_data[num].getFormat() == format) {
+ if (_data[num].format == format) {
return;
}
-
- Graphics::PixelBuffer dst(format, _width * _height, DisposeAfterUse::NO);
- dst.copyBuffer(0, _width * _height, _data[num]);
- _data[num].free();
- _data[num] = dst;
+ _data[num].convertToInPlace(format);
}
void BitmapData::convertToColorFormat(const Graphics::PixelFormat &format) {
diff --git a/engines/grim/bitmap.h b/engines/grim/bitmap.h
index 7785741e97..31f6e6b6eb 100644
--- a/engines/grim/bitmap.h
+++ b/engines/grim/bitmap.h
@@ -32,7 +32,7 @@
#include "engines/grim/pool.h"
namespace Graphics {
-class PixelBuffer;
+struct Surface;
}
namespace Common {
@@ -51,7 +51,7 @@ namespace Grim {
class BitmapData {
public:
BitmapData(const Common::String &fname);
- BitmapData(const Graphics::PixelBuffer &buf, int w, int h, const char *fname);
+ BitmapData(const Graphics::Surface &buf, int w, int h, const char *fname);
BitmapData();
~BitmapData();
@@ -72,7 +72,7 @@ public:
static BitmapData *getBitmapData(const Common::String &fname);
static Common::HashMap<Common::String, BitmapData *> *_bitmaps;
- const Graphics::PixelBuffer &getImageData(int num) const;
+ const Graphics::Surface &getImageData(int num) const;
/**
* Convert a bitmap to another color-format.
@@ -120,7 +120,7 @@ public:
uint32 _numLayers;
// private:
- Graphics::PixelBuffer *_data;
+ Graphics::Surface *_data;
void *_userData;
};
@@ -134,7 +134,7 @@ public:
* @param len the length of the data
*/
Bitmap(const Common::String &filename);
- Bitmap(const Graphics::PixelBuffer &buf, int width, int height, const char *filename);
+ Bitmap(const Graphics::Surface &buf, int width, int height, const char *filename);
Bitmap();
static int32 getStaticTag() { return MKTAG('V', 'B', 'U', 'F'); }
@@ -163,8 +163,8 @@ public:
int getWidth() const { return _data->_width; }
int getHeight() const { return _data->_height; }
- const Graphics::PixelBuffer &getData(int num) const { return _data->getImageData(num); }
- const Graphics::PixelBuffer &getData() const { return getData(_currImage); }
+ const Graphics::Surface &getData(int num) const { return _data->getImageData(num); }
+ const Graphics::Surface &getData() const { return getData(_currImage); }
BitmapData *getBitmapData() const { return _data; }
void *getTexIds() const { return _data->_texIds; }
int getNumTex() const { return _data->_numTex; }
diff --git a/engines/grim/emi/emi.cpp b/engines/grim/emi/emi.cpp
index 79d90cd0e3..897f1e4ca4 100644
--- a/engines/grim/emi/emi.cpp
+++ b/engines/grim/emi/emi.cpp
@@ -29,8 +29,8 @@
#include "engines/grim/set.h"
#include "engines/grim/gfx_base.h"
#include "engines/grim/actor.h"
-#include "graphics/pixelbuffer.h"
+#include "graphics/surface.h"
namespace Grim {
@@ -222,19 +222,19 @@ void EMIEngine::storeSaveGameImage(SaveGame *state) {
// copy the actual screenshot to the correct position
unsigned int texWidth = 256, texHeight = 128;
unsigned int size = texWidth * texHeight;
- Graphics::PixelBuffer buffer(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), size, DisposeAfterUse::YES);
- buffer.clear(size);
- for (unsigned int j = 0; j < 120; j++) {
- buffer.copyBuffer(j * texWidth, j * width, width, screenshot->getData(0));
- }
+ Graphics::Surface tmp = screenshot->getData(0);
+ Graphics::Surface *buffer = tmp.scale(texWidth, texHeight, true);
+ buffer->convertToInPlace(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
state->beginSection('SIMG');
- uint16 *data = (uint16 *)buffer.getRawBuffer();
+ uint16 *data = (uint16 *)buffer->getPixels();
for (unsigned int l = 0; l < size; l++) {
state->writeLEUint16(data[l]);
}
state->endSection();
delete screenshot;
+ buffer->free();
+ delete buffer;
}
void EMIEngine::temporaryStoreSaveGameImage() {
diff --git a/engines/grim/emi/lua_v2.cpp b/engines/grim/emi/lua_v2.cpp
index c14ad86155..45ce60eab6 100644
--- a/engines/grim/emi/lua_v2.cpp
+++ b/engines/grim/emi/lua_v2.cpp
@@ -24,21 +24,19 @@
#include "common/foreach.h"
#include "common/savefile.h"
+#include "graphics/surface.h"
+
#include "engines/grim/emi/lua_v2.h"
#include "engines/grim/emi/emi_registry.h"
#include "engines/grim/emi/sound/emisound.h"
#include "engines/grim/lua/lauxlib.h"
-#include "graphics/pixelbuffer.h"
-
#include "engines/grim/resource.h"
#include "engines/grim/set.h"
#include "engines/grim/grim.h"
#include "engines/grim/gfx_base.h"
#include "engines/grim/font.h"
-
#include "engines/grim/emi/layer.h"
#include "engines/grim/emi/emi.h"
-
#include "engines/grim/movie/movie.h"
namespace Grim {
@@ -507,7 +505,8 @@ void Lua_V2::ThumbnailFromFile() {
for (int l = 0; l < dataSize / 2; l++) {
data[l] = savedState->readLEUint16();
}
- Graphics::PixelBuffer buf(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), (byte *)data);
+ Graphics::Surface buf;
+ buf.init(width, height, width * 2, (void *)data, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
Bitmap *screenshot = new Bitmap(buf, width, height, "screenshot");
if (!screenshot) {
lua_pushnil();
@@ -519,7 +518,7 @@ void Lua_V2::ThumbnailFromFile() {
}
screenshot->_data->convertToColorFormat(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
- g_driver->createSpecialtyTexture(index, screenshot->getData(0).getRawBuffer(), width, height);
+ g_driver->createSpecialtyTexture(index, (const uint8 *)screenshot->getData(0).getPixels(), width, height);
delete screenshot;
delete[] data;
savedState->endSection();
diff --git a/engines/grim/gfx_base.cpp b/engines/grim/gfx_base.cpp
index 96e0a76c9f..0f7bfe0dca 100644
--- a/engines/grim/gfx_base.cpp
+++ b/engines/grim/gfx_base.cpp
@@ -40,9 +40,10 @@
#include "engines/grim/savegame.h"
#include "engines/grim/bitmap.h"
#include "engines/grim/grim.h"
-
#include "engines/grim/model.h"
+#include "graphics/surface.h"
+
namespace Grim {
GfxBase::GfxBase() :
@@ -160,7 +161,6 @@ Math::Matrix4 GfxBase::makeProjMatrix(float fov, float nclip, float fclip) {
return proj;
}
-
void GfxBase::createSpecialtyTexture(uint id, const uint8 *data, int width, int height) {
if (id >= _numSpecialtyTextures)
return;
@@ -175,42 +175,49 @@ void GfxBase::createSpecialtyTexture(uint id, const uint8 *data, int width, int
createTexture(&_specialtyTextures[id], data, nullptr, true);
}
-Bitmap *GfxBase::createScreenshotBitmap(const Graphics::PixelBuffer src, int w, int h, bool flipOrientation) {
- Graphics::PixelBuffer buffer(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), w * h, DisposeAfterUse::YES);
-
- int i1 = (_screenWidth * w - 1) / _screenWidth + 1;
- int j1 = (_screenHeight * h - 1) / _screenHeight + 1;
-
- for (int j = 0; j < j1; j++) {
- for (int i = 0; i < i1; i++) {
- int x0 = i * _screenWidth / w;
- int x1 = ((i + 1) * _screenWidth - 1) / w + 1;
- int y0 = j * _screenHeight / h;
- int y1 = ((j + 1) * _screenHeight - 1) / h + 1;
- uint16 sr = 0, sg = 0, sb = 0;
- for (int y = y0; y < y1; y++) {
- for (int x = x0; x < x1; x++) {
- uint8 r, g, b;
- src.getRGBAt(y * _screenWidth + x, r, g, b);
- sr += r;
- sg += g;
- sb += b;
- }
- }
- sr /= (x1 - x0) * (y1 - y0);
- sg /= (x1 - x0) * (y1 - y0);
- sb /= (x1 - x0) * (y1 - y0);
- if (g_grim->getGameType() == GType_MONKEY4) {
- buffer.setPixelAt( (flipOrientation ? j : (h - j - 1) ) * w + i, sr, sg, sb);
- } else {
- uint32 color = (sr + sg + sb) / 3;
- buffer.setPixelAt( (flipOrientation ? j : (h - j - 1) ) * w + i, color, color, color);
- }
+Bitmap *GfxBase::createScreenshotBitmap(Graphics::Surface *src, int w, int h, bool flipOrientation) {
+ Graphics::Surface buffer;
+ buffer.create(w, h, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
+ Common::Rect rec(0, 0, buffer.w, buffer.h);
+ buffer.fillRect(rec, 0);
+
+ int i1 = (_screenWidth * w - 1) / _screenWidth + 1;
+ int j1 = (_screenHeight * h - 1) / _screenHeight + 1;
+
+ for (int j = 0; j < j1; j++) {
+ for (int i = 0; i < i1; i++) {
+ int x0 = i * _screenWidth / w;
+ int x1 = ((i + 1) * _screenWidth - 1) / w + 1;
+ int y0 = j * _screenHeight / h;
+ int y1 = ((j + 1) * _screenHeight - 1) / h + 1;
+ uint16 sr = 0, sg = 0, sb = 0;
+ for (int y = y0; y < y1; y++) {
+ for (int x = x0; x < x1; x++) {
+ uint8 r, g, b;
+ uint32 pixel = src->getPixel(x, y);
+ src->format.colorToRGB(pixel, r, g, b);
+ sr += r;
+ sg += g;
+ sb += b;
}
+ }
+ uint32 pixel;
+ sr /= (x1 - x0) * (y1 - y0);
+ sg /= (x1 - x0) * (y1 - y0);
+ sb /= (x1 - x0) * (y1 - y0);
+ if (g_grim->getGameType() == GType_MONKEY4) {
+ pixel = buffer.format.RGBToColor(sr, sg, sb);
+ } else {
+ uint32 color = (sr + sg + sb) / 3;
+ pixel = buffer.format.RGBToColor(color, color, color);
+ }
+ buffer.setPixel(i, (flipOrientation ? j : (h - j - 1)), pixel);
}
+ }
- Bitmap *screenshot = new Bitmap(buffer, w, h, "screenshot");
- return screenshot;
+ Bitmap *screenshot = new Bitmap(buffer, w, h, "screenshot");
+ buffer.free();
+ return screenshot;
}
void GfxBase::makeScreenTextures() {
diff --git a/engines/grim/gfx_base.h b/engines/grim/gfx_base.h
index 78ea496293..d0983d21ab 100644
--- a/engines/grim/gfx_base.h
+++ b/engines/grim/gfx_base.h
@@ -26,7 +26,6 @@
#include "math/vector3d.h"
#include "math/quat.h"
-#include "graphics/pixelbuffer.h"
#include "common/str.h"
#include "common/rect.h"
@@ -275,7 +274,7 @@ public:
virtual void setBlendMode(bool additive) = 0;
protected:
- Bitmap *createScreenshotBitmap(const Graphics::PixelBuffer src, int w, int h, bool flipOrientation);
+ Bitmap *createScreenshotBitmap(Graphics::Surface *src, int w, int h, bool flipOrientation);
static const unsigned int _numSpecialtyTextures = 22;
Texture _specialtyTextures[_numSpecialtyTextures];
static const int _gameHeight = 480;
diff --git a/engines/grim/gfx_opengl.cpp b/engines/grim/gfx_opengl.cpp
index fe097daaf7..8154cd99e0 100644
--- a/engines/grim/gfx_opengl.cpp
+++ b/engines/grim/gfx_opengl.cpp
@@ -27,7 +27,6 @@
#if defined(USE_OPENGL_GAME)
#include "graphics/surface.h"
-#include "graphics/pixelbuffer.h"
#include "math/glmath.h"
@@ -1062,7 +1061,7 @@ void GfxOpenGL::createBitmap(BitmapData *bitmap) {
if (bitmap->_format != 1) {
for (int pic = 0; pic < bitmap->_numImages; pic++) {
- uint16 *zbufPtr = reinterpret_cast<uint16 *>(bitmap->getImageData(pic).getRawBuffer());
+ uint16 *zbufPtr = reinterpret_cast<uint16 *>(const_cast<void *>(bitmap->getImageData(pic).getPixels()));
for (int i = 0; i < (bitmap->_width * bitmap->_height); i++) {
uint16 val = READ_LE_UINT16(zbufPtr + i);
// fix the value if it is incorrectly set to the bitmap transparency color
@@ -1095,7 +1094,7 @@ void GfxOpenGL::createBitmap(BitmapData *bitmap) {
glGenTextures(bitmap->_numTex * bitmap->_numImages, textures);
byte *texData = nullptr;
- byte *texOut = nullptr;
+ const byte *texOut = nullptr;
GLint format = GL_RGBA;
GLint type = GL_UNSIGNED_BYTE;
@@ -1115,7 +1114,7 @@ void GfxOpenGL::createBitmap(BitmapData *bitmap) {
texData = new byte[bytes * bitmap->_width * bitmap->_height];
// Convert data to 32-bit RGBA format
byte *texDataPtr = texData;
- uint16 *bitmapData = reinterpret_cast<uint16 *>(bitmap->getImageData(pic).getRawBuffer());
+ const uint16 *bitmapData = reinterpret_cast<const uint16 *>(bitmap->getImageData(pic).getPixels());
for (int i = 0; i < bitmap->_width * bitmap->_height; i++, texDataPtr += bytes, bitmapData++) {
uint16 pixel = *bitmapData;
int r = pixel >> 11;
@@ -1134,9 +1133,9 @@ void GfxOpenGL::createBitmap(BitmapData *bitmap) {
texOut = texData;
} else if (bitmap->_format == 1 && bitmap->_colorFormat == BM_RGB1555) {
bitmap->convertToColorFormat(pic, Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
- texOut = (byte *)bitmap->getImageData(pic).getRawBuffer();
+ texOut = (const byte *)bitmap->getImageData(pic).getPixels();
} else {
- texOut = (byte *)bitmap->getImageData(pic).getRawBuffer();
+ texOut = (const byte *)bitmap->getImageData(pic).getPixels();
}
for (int i = 0; i < bitmap->_numTex; i++) {
@@ -1253,7 +1252,7 @@ void GfxOpenGL::drawBitmap(const Bitmap *bitmap, int dx, int dy, uint32 layer) {
if (bitmap->getFormat() == 5 && !_useDepthShader) {
// Only draw the manual zbuffer when enabled
if (bitmap->getActiveImage() - 1 < bitmap->getNumImages()) {
- drawDepthBitmap(dx, dy, bitmap->getWidth(), bitmap->getHeight(), (char *)bitmap->getData(bitmap->getActiveImage() - 1).getRawBuffer());
+ drawDepthBitmap(dx, dy, bitmap->getWidth(), bitmap->getHeight(), (const char *)bitmap->getData(bitmap->getActiveImage() - 1).getPixels());
} else {
warning("zbuffer image has index out of bounds! %d/%d", bitmap->getActiveImage(), bitmap->getNumImages());
}
@@ -1691,7 +1690,7 @@ void GfxOpenGL::destroyTexture(Texture *texture) {
}
}
-void GfxOpenGL::drawDepthBitmap(int x, int y, int w, int h, char *data) {
+void GfxOpenGL::drawDepthBitmap(int x, int y, int w, int h, const char *data) {
//if (num != 0) {
// warning("Animation not handled yet in GL texture path");
//}
@@ -1918,13 +1917,16 @@ void GfxOpenGL::drawEmergString(int x, int y, const char *text, const Color &fgC
}
Bitmap *GfxOpenGL::getScreenshot(int w, int h, bool useStored) {
- Graphics::PixelBuffer src(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), _screenWidth * _screenHeight, DisposeAfterUse::YES);
+ Graphics::Surface src;
+ src.create(_screenWidth, _screenHeight, Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
if (useStored) {
- memcpy(src.getRawBuffer(), _storedDisplay, _screenWidth * _screenHeight * 4);
+ memcpy(src.getPixels(), _storedDisplay, _screenWidth * _screenHeight * 4);
} else {
- glReadPixels(0, 0, _screenWidth, _screenHeight, GL_RGBA, GL_UNSIGNED_BYTE, src.getRawBuffer());
+ glReadPixels(0, 0, _screenWidth, _screenHeight, GL_RGBA, GL_UNSIGNED_BYTE, src.getPixels());
}
- return createScreenshotBitmap(src, w, h, false);
+ Bitmap *bmp = createScreenshotBitmap(&src, w, h, false);
+ src.free();
+ return bmp;
}
void GfxOpenGL::storeDisplay() {
diff --git a/engines/grim/gfx_opengl.h b/engines/grim/gfx_opengl.h
index 257e0a9d9c..a8cd1dc42c 100644
--- a/engines/grim/gfx_opengl.h
+++ b/engines/grim/gfx_opengl.h
@@ -135,7 +135,7 @@ public:
protected:
void createSpecialtyTextureFromScreen(uint id, uint8 *data, int x, int y, int width, int height) override;
- void drawDepthBitmap(int x, int y, int w, int h, char *data);
+ void drawDepthBitmap(int x, int y, int w, int h, const char *data);
void initExtensions();
private:
GLuint _emergFont;
diff --git a/engines/grim/gfx_opengl_shaders.cpp b/engines/grim/gfx_opengl_shaders.cpp
index cf6075570f..b54ce431cf 100644
--- a/engines/grim/gfx_opengl_shaders.cpp
+++ b/engines/grim/gfx_opengl_shaders.cpp
@@ -45,7 +45,6 @@
#if defined(USE_OPENGL_SHADERS)
#include "graphics/surface.h"
-#include "graphics/pixelbuffer.h"
#include "engines/grim/actor.h"
#include "engines/grim/bitmap.h"
@@ -1294,7 +1293,7 @@ void GfxOpenGLS::destroyTexture(Texture *texture) {
void GfxOpenGLS::createBitmap(BitmapData *bitmap) {
if (bitmap->_format != 1) {
for (int pic = 0; pic < bitmap->_numImages; pic++) {
- uint16 *zbufPtr = reinterpret_cast<uint16 *>(bitmap->getImageData(pic).getRawBuffer());
+ uint16 *zbufPtr = reinterpret_cast<uint16 *>(const_cast<void *>(bitmap->getImageData(pic).getPixels()));
for (int i = 0; i < (bitmap->_width * bitmap->_height); i++) {
uint16 val = READ_LE_UINT16(zbufPtr + i);
// fix the value if it is incorrectly set to the bitmap transparency color
@@ -1314,7 +1313,7 @@ void GfxOpenGLS::createBitmap(BitmapData *bitmap) {
glGenTextures(bitmap->_numTex * bitmap->_numImages, textures);
byte *texData = nullptr;
- byte *texOut = nullptr;
+ const byte *texOut = nullptr;
GLint format = GL_RGBA;
GLint type = GL_UNSIGNED_BYTE;
@@ -1328,7 +1327,7 @@ void GfxOpenGLS::createBitmap(BitmapData *bitmap) {
texData = new byte[bytes * bitmap->_width * bitmap->_height];
// Convert data to 32-bit RGBA format
byte *texDataPtr = texData;
- uint16 *bitmapData = reinterpret_cast<uint16 *>(bitmap->getImageData(pic).getRawBuffer());
+ const uint16 *bitmapData = reinterpret_cast<const uint16 *>(bitmap->getImageData(pic).getPixels());
for (int i = 0; i < bitmap->_width * bitmap->_height; i++, texDataPtr += bytes, bitmapData++) {
uint16 pixel = *bitmapData;
int r = pixel >> 11;
@@ -1347,9 +1346,9 @@ void GfxOpenGLS::createBitmap(BitmapData *bitmap) {
texOut = texData;
} else if (bitmap->_format == 1 && bitmap->_colorFormat == BM_RGB1555) {
bitmap->convertToColorFormat(pic, Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
- texOut = (byte *)bitmap->getImageData(pic).getRawBuffer();
+ texOut = (const byte *)bitmap->getImageData(pic).getPixels();
} else {
- texOut = (byte *)bitmap->getImageData(pic).getRawBuffer();
+ texOut = (const byte *)bitmap->getImageData(pic).getPixels();
}
int actualWidth = nextHigher2(bitmap->_width);
@@ -1444,7 +1443,7 @@ void GfxOpenGLS::drawBitmap(const Bitmap *bitmap, int dx, int dy, uint32 layer)
} else {
// Only draw the manual zbuffer when enabled
if (bitmap->getActiveImage() - 1 < bitmap->getNumImages()) {
- drawDepthBitmap(dx, dy, bitmap->getWidth(), bitmap->getHeight(), (char *)bitmap->getData(bitmap->getActiveImage() - 1).getRawBuffer());
+ drawDepthBitmap(dx, dy, bitmap->getWidth(), bitmap->getHeight(), (char *)const_cast<void *>(bitmap->getData(bitmap->getActiveImage() - 1).getPixels()));
} else {
warning("zbuffer image has index out of bounds! %d/%d", bitmap->getActiveImage(), bitmap->getNumImages());
}
@@ -2189,7 +2188,10 @@ static void readPixels(int x, int y, int width, int height, byte *buffer) {
}
Bitmap *GfxOpenGLS::getScreenshot(int w, int h, bool useStored) {
- Graphics::PixelBuffer src(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), _screenWidth * _screenHeight, DisposeAfterUse::YES);
+ Graphics::Surface src;
+ src.create(_screenWidth, _screenHeight, Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
+ Bitmap *bmp;
+
if (useStored) {
#ifdef USE_GLES2
GLuint frameBuffer;
@@ -2197,7 +2199,7 @@ Bitmap *GfxOpenGLS::getScreenshot(int w, int h, bool useStored) {
glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _storedDisplay, 0);
- readPixels(0, 0, _screenWidth, _screenHeight, src.getRawBuffer());
+ readPixels(0, 0, _screenWidth, _screenHeight, (uint8 *)src.getPixels());
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glDeleteFramebuffers(1, &frameBuffer);
@@ -2206,16 +2208,18 @@ Bitmap *GfxOpenGLS::getScreenshot(int w, int h, bool useStored) {
char *buffer = new char[_screenWidth * _screenHeight * 4];
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
- byte *rawBuf = src.getRawBuffer();
+ byte *rawBuf = (byte *)src.getPixels();
for (int i = 0; i < _screenHeight; i++) {
memcpy(&(rawBuf[(_screenHeight - i - 1) * _screenWidth * 4]), &buffer[4 * _screenWidth * i], _screenWidth * 4);
}
delete[] buffer;
#endif
} else {
- readPixels(0, 0, _screenWidth, _screenHeight, src.getRawBuffer());
+ readPixels(0, 0, _screenWidth, _screenHeight, (uint8 *)src.getPixels());
}
- return createScreenshotBitmap(src, w, h, true);
+ bmp = createScreenshotBitmap(&src, w, h, true);
+ src.free();
+ return bmp;
}
void GfxOpenGLS::createSpecialtyTextureFromScreen(uint id, uint8 *data, int x, int y, int width, int height) {
diff --git a/engines/grim/gfx_tinygl.cpp b/engines/grim/gfx_tinygl.cpp
index b0dd7c4452..53a2ee9776 100644
--- a/engines/grim/gfx_tinygl.cpp
+++ b/engines/grim/gfx_tinygl.cpp
@@ -49,8 +49,8 @@ GfxBase *CreateGfxTinyGL() {
GfxTinyGL::GfxTinyGL() :
_zb(nullptr), _alpha(1.f),
- _currentActor(nullptr), _smushImage(nullptr) {
- _storedDisplay = nullptr;
+ _currentActor(nullptr), _smushImage(nullptr),
+ _storedDisplay(nullptr) {
// TGL_LEQUAL as tglDepthFunc ensures that subsequent drawing attempts for
// the same triangles are not ignored by the depth test.
// That's necessary for EMI where some models have multiple faces which
@@ -63,6 +63,8 @@ GfxTinyGL::GfxTinyGL() :
}
GfxTinyGL::~GfxTinyGL() {
+ _storedDisplay->free();
+ delete _storedDisplay;
releaseMovieFrame();
for (unsigned int i = 0; i < _numSpecialtyTextures; i++) {
destroyTexture(&_specialtyTextures[i]);
@@ -90,8 +92,8 @@ void GfxTinyGL::setupScreen(int screenW, int screenH) {
TinyGL::glInit(_zb, 256);
tglEnableDirtyRects(ConfMan.getBool("dirtyrects"));
- _storedDisplay.create(_pixelFormat, _gameWidth * _gameHeight, DisposeAfterUse::YES);
- _storedDisplay.clear(_gameWidth * _gameHeight);
+ _storedDisplay = new Graphics::Surface;
+ _storedDisplay->create(_gameWidth, _gameHeight, _pixelFormat);
_currentShadowArray = nullptr;
@@ -886,8 +888,10 @@ void GfxTinyGL::createBitmap(BitmapData *bitmap) {
if (bitmap->_format != 1) {
for (int pic = 0; pic < bitmap->_numImages; pic++) {
- uint32 *buf = new uint32[bitmap->_width * bitmap->_height];
- uint16 *bufPtr = reinterpret_cast<uint16 *>(bitmap->getImageData(pic).getRawBuffer());
+ Graphics::Surface buffer;
+ buffer.create(bitmap->_width, bitmap->_height, Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
+ uint32 *buf = (uint32 *)buffer.getPixels();
+ const uint16 *bufPtr = (const uint16 *)(bitmap->getImageData(pic).getPixels());
for (int i = 0; i < (bitmap->_width * bitmap->_height); i++) {
uint16 val = READ_LE_UINT16(bufPtr + i);
// fix the value if it is incorrectly set to the bitmap transparency color
@@ -896,29 +900,16 @@ void GfxTinyGL::createBitmap(BitmapData *bitmap) {
}
buf[i] = ((uint32)val) * 0x10000 / 100 / (0x10000 - val) << 14;
}
- delete[] bufPtr;
- bitmap->_data[pic] = Graphics::PixelBuffer(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), (byte *)buf);
+ bitmap->_data[pic].free();
+ bitmap->_data[pic] = buffer;
imgs[pic] = Graphics::tglGenBlitImage();
- const Graphics::PixelBuffer &imageBuffer = bitmap->getImageData(pic);
- Graphics::Surface sourceSurface;
- sourceSurface.setPixels(imageBuffer.getRawBuffer());
- sourceSurface.format = imageBuffer.getFormat();
- sourceSurface.w = bitmap->_width;
- sourceSurface.h = bitmap->_height;
- sourceSurface.pitch = sourceSurface.w * imageBuffer.getFormat().bytesPerPixel;
- Graphics::tglUploadBlitImage(imgs[pic], sourceSurface, 0, false);
+ Graphics::tglUploadBlitImage(imgs[pic], bitmap->_data[pic], 0, false);
}
} else {
for (int i = 0; i < bitmap->_numImages; ++i) {
imgs[i] = Graphics::tglGenBlitImage();
- const Graphics::PixelBuffer &imageBuffer = bitmap->getImageData(i);
- Graphics::Surface sourceSurface;
- sourceSurface.setPixels(imageBuffer.getRawBuffer());
- sourceSurface.format = imageBuffer.getFormat();
- sourceSurface.w = bitmap->_width;
- sourceSurface.h = bitmap->_height;
- sourceSurface.pitch = sourceSurface.w * imageBuffer.getFormat().bytesPerPixel;
- Graphics::tglUploadBlitImage(imgs[i], sourceSurface, sourceSurface.format.ARGBToColor(0, 255, 0, 255), true);
+ const Graphics::Surface &imageBuffer = bitmap->getImageData(i);
+ Graphics::tglUploadBlitImage(imgs[i], imageBuffer, imageBuffer.format.ARGBToColor(0, 255, 0, 255), true);
}
}
}
@@ -1051,33 +1042,27 @@ void GfxTinyGL::createTextObject(TextObject *text) {
startColumn += font->getCharKernedWidth(ch);
}
- Graphics::PixelBuffer buf(_pixelFormat, width * height, DisposeAfterUse::YES);
+ Graphics::Surface buf;
+ buf.create(width, height, _pixelFormat);
uint8 *bitmapData = _textBitmap;
-
- int txData = 0;
- for (int i = 0; i < width * height; i++, txData++, bitmapData++) {
- byte pixel = *bitmapData;
- if (pixel == 0x00) {
- buf.setPixelAt(txData, kKitmapColorkey);
- } else if (pixel == 0x80) {
- buf.setPixelAt(txData, blackColor);
- } else if (pixel == 0xFF) {
- buf.setPixelAt(txData, color);
+ for (int iy = 0; iy < height; iy++) {
+ for (int ix = 0; ix < width; ix++, bitmapData++) {
+ byte pixel = *bitmapData;
+ if (pixel == 0x00) {
+ buf.setPixel(ix, iy, kKitmapColorkey);
+ } else if (pixel == 0x80) {
+ buf.setPixel(ix, iy, blackColor);
+ } else if (pixel == 0xFF) {
+ buf.setPixel(ix, iy, color);
+ }
}
}
userData[j].width = width;
userData[j].height = height;
-
- Graphics::Surface sourceSurface;
- sourceSurface.setPixels(buf.getRawBuffer());
- sourceSurface.format = buf.getFormat();
- sourceSurface.w = width;
- sourceSurface.h = height;
- sourceSurface.pitch = sourceSurface.w * buf.getFormat().bytesPerPixel;
userData[j].image = Graphics::tglGenBlitImage();
- Graphics::tglUploadBlitImage(userData[j].image, sourceSurface, kKitmapColorkey, true);
+ Graphics::tglUploadBlitImage(userData[j].image, buf, kKitmapColorkey, true);
userData[j].x = text->getLineX(j);
userData[j].y = text->getLineY(j);
@@ -1087,6 +1072,7 @@ void GfxTinyGL::createTextObject(TextObject *text) {
userData[j].y = 0;
}
+ buf.free();
delete[] _textBitmap;
}
}
@@ -1253,13 +1239,16 @@ void GfxTinyGL::drawEmergString(int x, int y, const char *text, const Color &fgC
}
Bitmap *GfxTinyGL::getScreenshot(int w, int h, bool useStored) {
+ Bitmap *bmp;
if (useStored) {
- return createScreenshotBitmap(_storedDisplay, w, h, true);
+ bmp = createScreenshotBitmap(_storedDisplay, w, h, true);
} else {
- Graphics::PixelBuffer src(_pixelFormat, _screenWidth * _screenHeight, DisposeAfterUse::YES);
- _zb->copyToBuffer(src);
- return createScreenshotBitmap(src, w, h, true);
+ Graphics::Surface *src = _zb->copyToBuffer(_pixelFormat);
+ bmp = createScreenshotBitmap(src, w, h, true);
+ src->free();
+ delete src;
}
+ return bmp;
}
void GfxTinyGL::createSpecialtyTextureFromScreen(uint id, uint8 *data, int x, int y, int width, int height) {
@@ -1269,7 +1258,9 @@ void GfxTinyGL::createSpecialtyTextureFromScreen(uint id, uint8 *data, int x, in
void GfxTinyGL::storeDisplay() {
TinyGL::tglPresentBuffer();
- _zb->copyToBuffer(_storedDisplay);
+ _storedDisplay->free();
+ delete _storedDisplay;
+ _storedDisplay = _zb->copyToBuffer(_pixelFormat);
}
void GfxTinyGL::copyStoredToDisplay() {
diff --git a/engines/grim/gfx_tinygl.h b/engines/grim/gfx_tinygl.h
index a880180da4..9b14486920 100644
--- a/engines/grim/gfx_tinygl.h
+++ b/engines/grim/gfx_tinygl.h
@@ -27,6 +27,10 @@
#include "graphics/tinygl/zgl.h"
+namespace Graphics {
+ struct Surface;
+}
+
namespace Grim {
class ModelNode;
@@ -132,7 +136,7 @@ private:
Graphics::PixelFormat _pixelFormat;
Graphics::BlitImage *_emergFont[96];
Graphics::BlitImage *_smushImage;
- Graphics::PixelBuffer _storedDisplay;
+ Graphics::Surface *_storedDisplay;
float _alpha;
const Actor *_currentActor;
TGLenum _depthFunc;
diff --git a/engines/grim/grim.cpp b/engines/grim/grim.cpp
index 1e3ac49f7d..2a1299f5f8 100644
--- a/engines/grim/grim.cpp
+++ b/engines/grim/grim.cpp
@@ -39,7 +39,6 @@
#include "backends/keymapper/keymap.h"
#include "backends/keymapper/standard-actions.h"
-#include "graphics/pixelbuffer.h"
#include "graphics/renderer.h"
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
@@ -1314,7 +1313,7 @@ void GrimEngine::storeSaveGameImage(SaveGame *state) {
int size = screenshot->getWidth() * screenshot->getHeight();
screenshot->setActiveImage(0);
screenshot->getBitmapData()->convertToColorFormat(image_format);
- uint16 *data = (uint16 *)screenshot->getData().getRawBuffer();
+ const uint16 *data = (const uint16 *)screenshot->getData().getPixels();
for (int l = 0; l < size; l++) {
state->writeLEUint16(data[l]);
}
diff --git a/engines/grim/lua_v1.cpp b/engines/grim/lua_v1.cpp
index 93a23a859e..fd3556a6b5 100644
--- a/engines/grim/lua_v1.cpp
+++ b/engines/grim/lua_v1.cpp
@@ -25,7 +25,7 @@
#include "common/system.h"
#include "common/config-manager.h"
-#include "graphics/pixelbuffer.h"
+#include "graphics/surface.h"
#include "graphics/renderer.h"
#include "math/matrix3.h"
@@ -40,7 +40,6 @@
#include "engines/grim/font.h"
#include "engines/grim/gfx_base.h"
#include "engines/grim/localize.h"
-
#include "engines/grim/lua/lauxlib.h"
#include "engines/grim/lua/luadebug.h"
@@ -513,7 +512,6 @@ void Lua_V1::GetCurrentScript() {
void Lua_V1::GetSaveGameImage() {
int width = 250, height = 188;
- Bitmap *screenshot;
int dataSize;
lua_Object param = lua_getparam(1);
@@ -533,8 +531,9 @@ void Lua_V1::GetSaveGameImage() {
for (int l = 0; l < dataSize / 2; l++) {
data[l] = savedState->readLEUint16();
}
- Graphics::PixelBuffer buf(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), (byte *)data);
- screenshot = new Bitmap(buf, width, height, "screenshot");
+ Graphics::Surface buf;
+ buf.init(width, height, width * 2, (void *)data, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
+ Bitmap *screenshot = new Bitmap(buf, width, height, "screenshot");
delete[] data;
if (screenshot) {
lua_pushusertag(screenshot->getId(), MKTAG('V','B','U','F'));
diff --git a/engines/icb/icb.cpp b/engines/icb/icb.cpp
index b998e7123d..0e224f3757 100644
--- a/engines/icb/icb.cpp
+++ b/engines/icb/icb.cpp
@@ -39,7 +39,6 @@
#include "audio/mixer.h"
-#include "graphics/pixelbuffer.h"
namespace ICB {
diff --git a/engines/icb/surface_manager.cpp b/engines/icb/surface_manager.cpp
index 799229db34..9342d8db36 100644
--- a/engines/icb/surface_manager.cpp
+++ b/engines/icb/surface_manager.cpp
@@ -244,15 +244,11 @@ void _surface_manager::Flip() {
flipTime = GetMicroTimer();
- Graphics::PixelBuffer srcBuf;
- srcBuf.set(screenSurface->format, (byte *)screenSurface->getPixels());
- Graphics::PixelBuffer dstBuf;
- dstBuf.create(g_system->getScreenFormat(), screenSurface->w * screenSurface->h, DisposeAfterUse::YES);
- dstBuf.copyBuffer(0, screenSurface->w * screenSurface->h, srcBuf);
-
- g_system->copyRectToScreen(dstBuf.getRawBuffer(), screenSurface->pitch,
- 0, 0, screenSurface->w, screenSurface->h);
+ Graphics::Surface *dstBuf = screenSurface->convertTo(g_system->getScreenFormat());
+ g_system->copyRectToScreen(dstBuf->getPixels(), dstBuf->pitch, 0, 0, dstBuf->w, dstBuf->h);
g_system->updateScreen();
+ dstBuf->free();
+ delete dstBuf;
flipTime = GetMicroTimer() - flipTime;
diff --git a/engines/icb/surface_manager.h b/engines/icb/surface_manager.h
index 039f38bacb..1f38f44af1 100644
--- a/engines/icb/surface_manager.h
+++ b/engines/icb/surface_manager.h
@@ -33,7 +33,6 @@
#include "engines/icb/common/px_types.h"
#include "graphics/surface.h"
-#include "graphics/pixelbuffer.h"
namespace ICB {
diff --git a/engines/myst3/gfx_tinygl.cpp b/engines/myst3/gfx_tinygl.cpp
index 2b87cf95f8..3b098c226d 100644
--- a/engines/myst3/gfx_tinygl.cpp
+++ b/engines/myst3/gfx_tinygl.cpp
@@ -273,11 +273,7 @@ void TinyGLRenderer::drawTexturedRect3D(const Math::Vector3d &topLeft, const Mat
}
Graphics::Surface *TinyGLRenderer::getScreenshot() {
- Graphics::Surface *s = new Graphics::Surface();
- s->create(kOriginalWidth, kOriginalHeight, Texture::getRGBAPixelFormat());
- Graphics::PixelBuffer buf(s->format, (byte *)s->getPixels());
- _fb->copyToBuffer(buf);
- return s;
+ return _fb->copyToBuffer(Texture::getRGBAPixelFormat());
}
void TinyGLRenderer::flipBuffer() {
diff --git a/engines/stark/gfx/opengl.cpp b/engines/stark/gfx/opengl.cpp
index 87ddbfff73..e9f82c4dd5 100644
--- a/engines/stark/gfx/opengl.cpp
+++ b/engines/stark/gfx/opengl.cpp
@@ -36,7 +36,6 @@
#include "engines/stark/scene.h"
#include "engines/stark/services/services.h"
-#include "graphics/pixelbuffer.h"
#include "graphics/surface.h"
namespace Stark {
diff --git a/engines/stark/gfx/opengls.cpp b/engines/stark/gfx/opengls.cpp
index fc9ff22323..28e206b3d3 100644
--- a/engines/stark/gfx/opengls.cpp
+++ b/engines/stark/gfx/opengls.cpp
@@ -34,7 +34,6 @@
#include "engines/stark/gfx/openglsfade.h"
#include "engines/stark/gfx/opengltexture.h"
-#include "graphics/pixelbuffer.h"
#include "graphics/surface.h"
#include "graphics/opengl/shader.h"
diff --git a/engines/stark/gfx/tinygl.cpp b/engines/stark/gfx/tinygl.cpp
index 5cd7e9480b..8830ee6dd7 100644
--- a/engines/stark/gfx/tinygl.cpp
+++ b/engines/stark/gfx/tinygl.cpp
@@ -36,7 +36,6 @@
#include "engines/stark/scene.h"
#include "engines/stark/services/services.h"
-#include "graphics/pixelbuffer.h"
#include "graphics/surface.h"
namespace Stark {
@@ -176,13 +175,13 @@ Common::Rect TinyGLDriver::getUnscaledViewport() const {
}
Graphics::Surface *TinyGLDriver::getViewportScreenshot() const {
- Graphics::Surface *tmp = new Graphics::Surface();
- tmp->create(kOriginalWidth, kOriginalHeight, g_system->getScreenFormat());
+ Graphics::Surface *tmp = _fb->copyToBuffer(getRGBAPixelFormat());
Graphics::Surface *s = new Graphics::Surface();
s->create(_viewport.width(), _viewport.height(), getRGBAPixelFormat());
- Graphics::PixelBuffer buf(tmp->format, (byte *)tmp->getPixels());
- _fb->copyToBuffer(buf);
- s->copyRectToSurface(tmp->getBasePtr(_viewport.left, _viewport.top), tmp->pitch, 0, 0, _viewport.width(), _viewport.height());
+ byte *src = (byte *)tmp->getPixels();
+ s->copyRectToSurface(src + tmp->pitch * _viewport.top + _viewport.left * tmp->format.bytesPerPixel,
+ tmp->pitch, 0, 0, _viewport.width(), _viewport.height());
+ tmp->free();
delete tmp;
return s;
}
diff --git a/graphics/tinygl/zbuffer.h b/graphics/tinygl/zbuffer.h
index 2340b3bfe3..70f1ede77a 100644
--- a/graphics/tinygl/zbuffer.h
+++ b/graphics/tinygl/zbuffer.h
@@ -30,8 +30,10 @@
#define GRAPHICS_TINYGL_ZBUFFER_H_
#include "graphics/pixelbuffer.h"
+#include "graphics/surface.h"
#include "graphics/tinygl/texelbuffer.h"
#include "graphics/tinygl/gl.h"
+
#include "common/rect.h"
namespace TinyGL {
@@ -111,7 +113,7 @@ struct FrameBuffer {
void clearRegion(int x, int y, int w, int h,int clear_z, int z, int clear_color, int r, int g, int b);
byte *getPixelBuffer() {
- return pbuf.getRawBuffer(0);
+ return pbuf.getRawBuffer();
}
unsigned int *getZBuffer() {
@@ -375,12 +377,10 @@ struct FrameBuffer {
}
}
- void copyToBuffer(Graphics::PixelBuffer &buf) {
- buf.copyBuffer(0, xsize * ysize, pbuf);
- }
-
- void copyFromBuffer(Graphics::PixelBuffer buf) {
- pbuf.copyBuffer(0, xsize * ysize, buf);
+ Graphics::Surface *copyToBuffer(const Graphics::PixelFormat &dstFormat) {
+ Graphics::Surface tmp;
+ tmp.init(xsize, ysize, linesize, pbuf.getRawBuffer(), cmode);
+ return tmp.convertTo(dstFormat);
}
void enableBlending(bool enable) {
More information about the Scummvm-git-logs
mailing list