TWINE: switch to managed surfaces

This commit is contained in:
Martin Gerhardy 2020-10-21 14:47:25 +02:00 committed by Eugene Sandulenko
parent e652a0e93b
commit 33d27512f1
5 changed files with 14 additions and 9 deletions

View File

@ -764,7 +764,7 @@ void Redraw::drawBubble(int32 actorIdx) {
}
void Redraw::zoomScreenScale() {
Graphics::Surface zoomWorkVideoBuffer;
Graphics::ManagedSurface zoomWorkVideoBuffer;
zoomWorkVideoBuffer.copyFrom(_engine->workVideoBuffer);
// TODO: this is broken

View File

@ -248,7 +248,7 @@ void Screens::copyScreen(const uint8 *source, uint8 *destination) {
}
}
void Screens::copyScreen(const Graphics::Surface& source, Graphics::Surface &destination) {
void Screens::copyScreen(const Graphics::ManagedSurface& source, Graphics::ManagedSurface &destination) {
copyScreen((const uint8 *)source.getPixels(), (uint8 *)destination.getPixels());
}

View File

@ -24,6 +24,7 @@
#define TWINE_SCREENS_H
#include "common/scummsys.h"
#include "graphics/managed_surface.h"
#include "graphics/surface.h"
#include "twine/twine.h"
@ -167,7 +168,7 @@ public:
* @param destination screen buffer
*/
void copyScreen(const uint8 *source, uint8 *destination);
void copyScreen(const Graphics::Surface &source, Graphics::Surface &destination);
void copyScreen(const Graphics::ManagedSurface &source, Graphics::ManagedSurface &destination);
/** Clear front buffer screen */
void clearScreen();

View File

@ -30,6 +30,7 @@
#include "common/system.h"
#include "common/textconsole.h"
#include "engines/util.h"
#include "graphics/managed_surface.h"
#include "graphics/palette.h"
#include "graphics/surface.h"
#include "gui/debugger.h"
@ -815,12 +816,14 @@ void TwinEEngine::flip() {
}
void TwinEEngine::copyBlockPhys(int32 left, int32 top, int32 right, int32 bottom) {
// TODO: fix this
assert(left < right);
assert(top < bottom);
// TODO: fix this - looks like the palette includes a color key at pos 0
g_system->copyRectToScreen(frontVideoBuffer.getPixels(), frontVideoBuffer.pitch, left, top, right - left + 1, bottom - top + 1);
g_system->updateScreen();
}
void TwinEEngine::crossFade(const Graphics::Surface &buffer, uint8 *palette) {
void TwinEEngine::crossFade(const Graphics::ManagedSurface &buffer, uint8 *palette) {
g_system->getPaletteManager()->setPalette(palette, 0, 256);
// TODO: implement cross fading
g_system->copyRectToScreen(buffer.getPixels(), buffer.pitch, 0, 0, buffer.w, buffer.h);
@ -1003,7 +1006,7 @@ void TwinEEngine::drawText(int32 x, int32 y, const char *string, int32 center) {
SDL_Color white = {0xFF, 0xFF, 0xFF, 0};
SDL_Color *forecol = &white;
SDL_Rect rectangle;
Graphics::Surface *text = TTF_RenderText_Solid(font, string, *forecol);
Graphics::ManagedSurface *text = TTF_RenderText_Solid(font, string, *forecol);
if (center) {
rectangle.x = x - (text->w / 2);

View File

@ -27,6 +27,7 @@
#include "common/random.h"
#include "engines/engine.h"
#include "graphics/managed_surface.h"
#include "graphics/pixelformat.h"
#include "graphics/surface.h"
#include "twine/actor.h"
@ -220,9 +221,9 @@ public:
int16 rightMouse = 0;
/** Work video buffer */
Graphics::Surface workVideoBuffer;
Graphics::ManagedSurface workVideoBuffer;
/** Main game video buffer */
Graphics::Surface frontVideoBuffer;
Graphics::ManagedSurface frontVideoBuffer;
/** temporary screen table */
int32 screenLookupTable[2000]{0};
@ -282,7 +283,7 @@ public:
* @param buffer screen buffer
* @param palette new palette to cross fade
*/
void crossFade(const Graphics::Surface &buffer, uint8 *palette);
void crossFade(const Graphics::ManagedSurface &buffer, uint8 *palette);
/** Handle keyboard pressed keys */
void readKeys();