mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-12 20:17:49 +00:00
TRECISION: Improve handling of pixel formats - bug #12645
This commit is contained in:
parent
2f3a09dc10
commit
5ddcff361c
@ -39,8 +39,7 @@
|
|||||||
|
|
||||||
namespace Trecision {
|
namespace Trecision {
|
||||||
|
|
||||||
GraphicsManager::GraphicsManager(TrecisionEngine *vm) : _vm(vm), _font(nullptr), kImageFormat(2, 5, 5, 5, 0, 10, 5, 0, 0) {
|
GraphicsManager::GraphicsManager(TrecisionEngine *vm) : _vm(vm), _font(nullptr) {
|
||||||
// RGB555
|
|
||||||
for (int i = 0; i < 3; ++i)
|
for (int i = 0; i < 3; ++i)
|
||||||
_bitMask[i] = 0;
|
_bitMask[i] = 0;
|
||||||
}
|
}
|
||||||
@ -59,23 +58,23 @@ GraphicsManager::~GraphicsManager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GraphicsManager::init() {
|
bool GraphicsManager::init() {
|
||||||
const Graphics::PixelFormat *bestFormat = &kImageFormat;
|
// Find a suitable 16-bit format
|
||||||
|
const Graphics::PixelFormat rgb555(2, 5, 5, 5, 0, 10, 5, 0, 0);
|
||||||
// Find a 16-bit format, currently we don't support other color depths
|
|
||||||
Common::List<Graphics::PixelFormat> formats = g_system->getSupportedFormats();
|
Common::List<Graphics::PixelFormat> formats = g_system->getSupportedFormats();
|
||||||
bool found = false;
|
for (Common::List<Graphics::PixelFormat>::iterator i = formats.begin(); i != formats.end(); ++i) {
|
||||||
for (Common::List<Graphics::PixelFormat>::const_iterator i = formats.begin(); i != formats.end(); ++i) {
|
if (i->bytesPerPixel != 2 || i->aBits()) {
|
||||||
if (i->bytesPerPixel == 2) {
|
i = formats.reverse_erase(i);
|
||||||
bestFormat = &*i;
|
} else if (*i == rgb555) {
|
||||||
found = true;
|
formats.clear();
|
||||||
|
formats.push_back(rgb555);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (formats.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
initGraphics(MAXX, MAXY, bestFormat);
|
initGraphics(MAXX, MAXY, formats);
|
||||||
|
|
||||||
_screenFormat = g_system->getScreenFormat();
|
_screenFormat = g_system->getScreenFormat();
|
||||||
if (_screenFormat.bytesPerPixel != 2)
|
if (_screenFormat.bytesPerPixel != 2)
|
||||||
@ -235,12 +234,13 @@ void GraphicsManager::copyToScreen(int x, int y, int w, int h) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsManager::readSurface(Common::SeekableReadStream *stream, Graphics::Surface *surface, uint16 width, uint16 height, uint16 count) {
|
void GraphicsManager::readSurface(Common::SeekableReadStream *stream, Graphics::Surface *surface, uint16 width, uint16 height, uint16 count) {
|
||||||
surface->create(width * count, height, kImageFormat);
|
Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
|
||||||
|
surface->create(width * count, height, pixelFormat);
|
||||||
|
|
||||||
for (uint16 i = 0; i < count; ++i) {
|
for (uint16 i = 0; i < count; ++i) {
|
||||||
for (uint16 y = 0; y < height; ++y) {
|
for (uint16 y = 0; y < height; ++y) {
|
||||||
void *p = surface->getBasePtr(width * i, y);
|
void *p = surface->getBasePtr(width * i, y);
|
||||||
stream->read(p, width * kImageFormat.bytesPerPixel);
|
stream->read(p, width * pixelFormat.bytesPerPixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +344,7 @@ void GraphicsManager::clearScreenBufferSaveSlotDescriptions() {
|
|||||||
|
|
||||||
uint16 GraphicsManager::convertToScreenFormat(uint16 color) const {
|
uint16 GraphicsManager::convertToScreenFormat(uint16 color) const {
|
||||||
uint8 r, g, b;
|
uint8 r, g, b;
|
||||||
kImageFormat.colorToRGB(color, r, g, b);
|
g_system->getScreenFormat().colorToRGB(color, r, g, b);
|
||||||
return (uint16)_screenFormat.RGBToColor(r, g, b);
|
return (uint16)_screenFormat.RGBToColor(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +53,6 @@ class GraphicsManager {
|
|||||||
|
|
||||||
Common::List<Common::Rect> _dirtyRects;
|
Common::List<Common::Rect> _dirtyRects;
|
||||||
|
|
||||||
const Graphics::PixelFormat kImageFormat;
|
|
||||||
|
|
||||||
uint16 aliasing(uint32 val1, uint32 val2, uint8 num);
|
uint16 aliasing(uint32 val1, uint32 val2, uint8 num);
|
||||||
void drawCharPixel(uint16 y, uint16 charLeft, uint16 charRight, Common::Rect rect, Common::Rect subtitleRect, uint16 color, Graphics::Surface *externalSurface = nullptr);
|
void drawCharPixel(uint16 y, uint16 charLeft, uint16 charRight, Common::Rect rect, Common::Rect subtitleRect, uint16 color, Graphics::Surface *externalSurface = nullptr);
|
||||||
void initCursor();
|
void initCursor();
|
||||||
|
Loading…
Reference in New Issue
Block a user