From b3f0eb8a9db27d3b0659eeb7ce53c69849342439 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 17 Apr 2011 16:31:49 +0200 Subject: SWORD25: Prefer Surface::create taking a PixelFormat over the one taking a byte depth. I am not 100% sure whether the surfaces all use the same format as the screen, but a quick test showed that it still works fine. In case this is wrong please set them up with the correct format. --- engines/sword25/fmv/theora_decoder.cpp | 2 +- engines/sword25/gfx/graphicengine.cpp | 6 ++++-- engines/sword25/gfx/image/renderedimage.cpp | 2 +- engines/sword25/gfx/screenshot.cpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) (limited to 'engines/sword25') diff --git a/engines/sword25/fmv/theora_decoder.cpp b/engines/sword25/fmv/theora_decoder.cpp index e9901c04b0..4f6f52509d 100644 --- a/engines/sword25/fmv/theora_decoder.cpp +++ b/engines/sword25/fmv/theora_decoder.cpp @@ -289,7 +289,7 @@ bool TheoraDecoder::loadStream(Common::SeekableReadStream *stream) { _surface = new Graphics::Surface(); - _surface->create(_theoraInfo.frame_width, _theoraInfo.frame_height, 4); + _surface->create(_theoraInfo.frame_width, _theoraInfo.frame_height, g_system->getScreenFormat()); return true; } diff --git a/engines/sword25/gfx/graphicengine.cpp b/engines/sword25/gfx/graphicengine.cpp index 502d2d3b2a..8bdf2a4a6e 100644 --- a/engines/sword25/gfx/graphicengine.cpp +++ b/engines/sword25/gfx/graphicengine.cpp @@ -112,8 +112,10 @@ bool GraphicEngine::init(int width, int height, int bitDepth, int backbufferCoun _screenRect.right = _width; _screenRect.bottom = _height; - _backSurface.create(width, height, 4); - _frameBuffer.create(width, height, 4); + const Graphics::PixelFormat format = g_system->getScreenFormat(); + + _backSurface.create(width, height, format); + _frameBuffer.create(width, height, format); // Standardmäßig ist Vsync an. setVsync(true); diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp index b740c0ec68..560663896f 100644 --- a/engines/sword25/gfx/image/renderedimage.cpp +++ b/engines/sword25/gfx/image/renderedimage.cpp @@ -409,7 +409,7 @@ void RenderedImage::copyDirectly(int posX, int posY) { */ Graphics::Surface *RenderedImage::scale(const Graphics::Surface &srcImage, int xSize, int ySize) { Graphics::Surface *s = new Graphics::Surface(); - s->create(xSize, ySize, srcImage.bytesPerPixel); + s->create(xSize, ySize, srcImage.format); int *horizUsage = scaleLine(xSize, srcImage.w); int *vertUsage = scaleLine(ySize, srcImage.h); diff --git a/engines/sword25/gfx/screenshot.cpp b/engines/sword25/gfx/screenshot.cpp index 35e94976eb..e06ccb8051 100644 --- a/engines/sword25/gfx/screenshot.cpp +++ b/engines/sword25/gfx/screenshot.cpp @@ -134,7 +134,7 @@ Common::SeekableReadStream *Screenshot::createThumbnail(Graphics::Surface *data) // Buffer for the output thumbnail Graphics::Surface thumbnail; - thumbnail.create(200, 125, 4); + thumbnail.create(200, 125, g_system->getScreenFormat()); // Über das Zielbild iterieren und einen Pixel zur Zeit berechnen. uint x, y; -- cgit v1.2.3 From c3669443ece9e29d37ddfdce5614c628717a34b9 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 17 Apr 2011 17:29:37 +0200 Subject: SWORD25: Prefer Surface::format over Surface::bytesPerPixel. --- engines/sword25/fmv/movieplayer.cpp | 2 +- engines/sword25/gfx/image/renderedimage.cpp | 6 ++++-- engines/sword25/gfx/screenshot.cpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'engines/sword25') diff --git a/engines/sword25/fmv/movieplayer.cpp b/engines/sword25/fmv/movieplayer.cpp index 177bd38303..8ab64fa7a8 100644 --- a/engines/sword25/fmv/movieplayer.cpp +++ b/engines/sword25/fmv/movieplayer.cpp @@ -121,7 +121,7 @@ void MoviePlayer::update() { const Graphics::Surface *s = _decoder.decodeNextFrame(); if (s) { // Transfer the next frame - assert(s->bytesPerPixel == 4); + assert(s->format.bytesPerPixel == 4); #ifdef THEORA_INDIRECT_RENDERING byte *frameData = (byte *)s->getBasePtr(0, 0); diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp index 560663896f..494b631f14 100644 --- a/engines/sword25/gfx/image/renderedimage.cpp +++ b/engines/sword25/gfx/image/renderedimage.cpp @@ -188,6 +188,8 @@ bool RenderedImage::blit(int posX, int posY, int flipping, Common::Rect *pPartRe // Create an encapsulating surface for the data Graphics::Surface srcImage; srcImage.bytesPerPixel = 4; + // TODO: Is the data really in the screen format? + srcImage.format = g_system->getScreenFormat(); srcImage.pitch = _width * 4; srcImage.w = _width; srcImage.h = _height; @@ -420,8 +422,8 @@ Graphics::Surface *RenderedImage::scale(const Graphics::Surface &srcImage, int x byte *destP = (byte *)s->getBasePtr(0, yp); for (int xp = 0; xp < xSize; ++xp) { - const byte *tempSrcP = srcP + (horizUsage[xp] * srcImage.bytesPerPixel); - for (int byteCtr = 0; byteCtr < srcImage.bytesPerPixel; ++byteCtr) { + const byte *tempSrcP = srcP + (horizUsage[xp] * srcImage.format.bytesPerPixel); + for (int byteCtr = 0; byteCtr < srcImage.format.bytesPerPixel; ++byteCtr) { *destP++ = *tempSrcP++; } } diff --git a/engines/sword25/gfx/screenshot.cpp b/engines/sword25/gfx/screenshot.cpp index e06ccb8051..5d25626727 100644 --- a/engines/sword25/gfx/screenshot.cpp +++ b/engines/sword25/gfx/screenshot.cpp @@ -127,7 +127,7 @@ Common::SeekableReadStream *Screenshot::createThumbnail(Graphics::Surface *data) // generates a pixel of the target image. Finally, the result as a PNG file is stored as a file. // The source image must be 800x600. - if (data->w != 800 || data->h != 600 || data->bytesPerPixel != 4) { + if (data->w != 800 || data->h != 600 || data->format.bytesPerPixel != 4) { error("The sreenshot dimensions have to be 800x600 in order to be saved as a thumbnail."); return false; } -- cgit v1.2.3 From da734a4af024a72ee155bc25d6e45f994de6b060 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 17 Apr 2011 21:27:34 +0200 Subject: ALL/GRAPHICS: Remove Surface::bytesPerPixel. --- engines/sword25/gfx/image/renderedimage.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/sword25') diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp index 494b631f14..806d9b27ad 100644 --- a/engines/sword25/gfx/image/renderedimage.cpp +++ b/engines/sword25/gfx/image/renderedimage.cpp @@ -187,7 +187,6 @@ bool RenderedImage::blit(int posX, int posY, int flipping, Common::Rect *pPartRe // Create an encapsulating surface for the data Graphics::Surface srcImage; - srcImage.bytesPerPixel = 4; // TODO: Is the data really in the screen format? srcImage.format = g_system->getScreenFormat(); srcImage.pitch = _width * 4; -- cgit v1.2.3