diff options
author | Einar Johan Trøan Sømåen | 2012-07-26 15:59:26 +0200 |
---|---|---|
committer | Einar Johan Trøan Sømåen | 2012-07-26 15:59:26 +0200 |
commit | ef11f9d0c53cbdd9d88a99143de6f43f34d7e24d (patch) | |
tree | 8dfaee0ba16e18a8e3772dd5afc9123d5c4e78d2 /engines/wintermute/base/gfx | |
parent | 38507fa9895620639d8733dbb4e085dfb2282a33 (diff) | |
download | scummvm-rg350-ef11f9d0c53cbdd9d88a99143de6f43f34d7e24d.tar.gz scummvm-rg350-ef11f9d0c53cbdd9d88a99143de6f43f34d7e24d.tar.bz2 scummvm-rg350-ef11f9d0c53cbdd9d88a99143de6f43f34d7e24d.zip |
WINTERMUTE: Run Astyle with add-braces to break one-line statements into easier-to-read-code.
Diffstat (limited to 'engines/wintermute/base/gfx')
-rw-r--r-- | engines/wintermute/base/gfx/base_image.cpp | 76 | ||||
-rw-r--r-- | engines/wintermute/base/gfx/base_renderer.cpp | 28 | ||||
-rw-r--r-- | engines/wintermute/base/gfx/base_surface.cpp | 8 | ||||
-rw-r--r-- | engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 55 | ||||
-rw-r--r-- | engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp | 41 |
5 files changed, 129 insertions, 79 deletions
diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 09a78a748b..571deed793 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -53,15 +53,11 @@ BaseImage::BaseImage(BaseFileManager *fileManager) { //////////////////////////////////////////////////////////////////////
BaseImage::~BaseImage() {
- /* delete _bitmap; */
delete _decoder;
if (_deletableSurface) {
_deletableSurface->free();
}
delete _deletableSurface;
-#if 0
- if (_bitmap) FreeImage_Unload(_bitmap);
-#endif
}
bool BaseImage::loadFile(const Common::String &filename) {
@@ -82,7 +78,9 @@ bool BaseImage::loadFile(const Common::String &filename) { }
_filename = filename;
Common::SeekableReadStream *file = _fileManager->openFile(filename.c_str());
- if (!file) return false;
+ if (!file) {
+ return false;
+ }
_decoder->loadStream(*file);
_surface = _decoder->getSurface();
@@ -93,7 +91,9 @@ bool BaseImage::loadFile(const Common::String &filename) { }
byte BaseImage::getAlphaAt(int x, int y) const {
- if (!_surface) return 0xFF;
+ if (!_surface) {
+ return 0xFF;
+ }
uint32 color = *(uint32 *)_surface->getBasePtr(x, y);
byte r, g, b, a;
_surface->format.colorToARGB(color, a, r, g, b);
@@ -107,12 +107,6 @@ void BaseImage::copyFrom(const Graphics::Surface *surface) { //////////////////////////////////////////////////////////////////////////
bool BaseImage::saveBMPFile(const char *filename) const {
-#if 0
- if (!_bitmap) return STATUS_FAILED;
-
- if (FreeImage_Save(FIF_BMP, _bitmap, filename)) return STATUS_OK;
- else return STATUS_FAILED;
-#endif
warning("BaseImage::saveBMPFile - stubbed"); // TODO
return false;
}
@@ -121,10 +115,16 @@ bool BaseImage::saveBMPFile(const char *filename) const { //////////////////////////////////////////////////////////////////////////
bool BaseImage::resize(int newWidth, int newHeight) {
#if 0
- if (!_bitmap) return STATUS_FAILED;
+ if (!_bitmap) {
+ return STATUS_FAILED;
+ }
- if (newWidth == 0) NewWidth = FreeImage_GetWidth(_bitmap);
- if (newHeight == 0) NewHeight = FreeImage_GetHeight(_bitmap);
+ if (newWidth == 0) {
+ NewWidth = FreeImage_GetWidth(_bitmap);
+ }
+ if (newHeight == 0) {
+ NewHeight = FreeImage_GetHeight(_bitmap);
+ }
FIBITMAP *newImg = FreeImage_Rescale(_bitmap, NewWidth, NewHeight, FILTER_BILINEAR);
@@ -132,7 +132,9 @@ bool BaseImage::resize(int newWidth, int newHeight) { FreeImage_Unload(_bitmap);
_bitmap = newImg;
return STATUS_OK;
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
#endif
return false;
}
@@ -140,7 +142,9 @@ bool BaseImage::resize(int newWidth, int newHeight) { //////////////////////////////////////////////////////////////////////////
bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const {
- if (!_surface) return false;
+ if (!_surface) {
+ return false;
+ }
/* The following is just copied over and inverted to write-ops from the BMP-decoder */
stream->writeByte('B');
@@ -164,8 +168,9 @@ bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const { stream->writeUint32LE(width);
stream->writeUint32LE((uint32)height);
- if (width == 0 || height == 0)
+ if (width == 0 || height == 0) {
return false;
+ }
if (height < 0) {
warning("Right-side up bitmaps not supported");
@@ -194,8 +199,9 @@ bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const { Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8();
// BGRA for 24bpp
- if (bitsPerPixel == 24)
+ if (bitsPerPixel == 24) {
format = Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0);
+ }
Graphics::Surface *surface = _surface->convertTo(format);
@@ -219,36 +225,22 @@ bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const { surface->free();
delete surface;
return true;
-
- //*BufferSize = 0;
-#if 0
- FIMEMORY *fiMem = FreeImage_OpenMemory();
- FreeImage_SaveToMemory(FIF_PNG, _bitmap, fiMem);
- uint32 size;
- byte *data;
- FreeImage_AcquireMemory(fiMem, &data, &size);
-
-
- byte *Buffer = new byte[size];
- memcpy(Buffer, data, size);
-
- FreeImage_CloseMemory(fiMem);
-
- if (BufferSize) *BufferSize = size;
-
- return Buffer;
-#endif
- return false;
}
//////////////////////////////////////////////////////////////////////////
bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) {
#if 0
- if (_bitmap) FreeImage_Unload(_bitmap);
+ if (_bitmap) {
+ FreeImage_Unload(_bitmap);
+ }
- if (NewWidth == 0) NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap());
- if (NewHeight == 0) NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap());
+ if (NewWidth == 0) {
+ NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap());
+ }
+ if (NewHeight == 0) {
+ NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap());
+ }
_bitmap = FreeImage_Rescale(OrigImage->GetBitmap(), NewWidth, NewHeight, FILTER_BILINEAR);
#endif
diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 66b7f513bf..168aa75d91 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -89,13 +89,19 @@ BaseObject *BaseRenderer::getObjectAt(int x, int y) { yy = height - yy;
}
- if (!_rectList[i]->_frame->_surface->isTransparentAt(xx, yy)) return _rectList[i]->_owner;
+ if (!_rectList[i]->_frame->_surface->isTransparentAt(xx, yy)) {
+ return _rectList[i]->_owner;
+ }
}
// region
else if (_rectList[i]->_region) {
- if (_rectList[i]->_region->pointInRegion(x + _rectList[i]->_offsetX, y + _rectList[i]->_offsetY)) return _rectList[i]->_owner;
+ if (_rectList[i]->_region->pointInRegion(x + _rectList[i]->_offsetX, y + _rectList[i]->_offsetY)) {
+ return _rectList[i]->_owner;
+ }
}
- } else return _rectList[i]->_owner;
+ } else {
+ return _rectList[i]->_owner;
+ }
}
}
@@ -208,10 +214,18 @@ bool BaseRenderer::unclipCursor() { //////////////////////////////////////////////////////////////////////////
bool BaseRenderer::pointInViewport(Point32 *p) {
- if (p->x < _drawOffsetX) return false;
- if (p->y < _drawOffsetY) return false;
- if (p->x > _drawOffsetX + _width) return false;
- if (p->y > _drawOffsetY + _height) return false;
+ if (p->x < _drawOffsetX) {
+ return false;
+ }
+ if (p->y < _drawOffsetY) {
+ return false;
+ }
+ if (p->x > _drawOffsetX + _width) {
+ return false;
+ }
+ if (p->y > _drawOffsetY + _height) {
+ return false;
+ }
return true;
}
diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp index 684236ac7f..68e3e3d26c 100644 --- a/engines/wintermute/base/gfx/base_surface.cpp +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -54,7 +54,9 @@ BaseSurface::BaseSurface(BaseGame *inGame): BaseClass(inGame) { //////////////////////////////////////////////////////////////////////
BaseSurface::~BaseSurface() {
- if (_pixelOpReady) endPixelOp();
+ if (_pixelOpReady) {
+ endPixelOp();
+ }
}
@@ -139,7 +141,9 @@ bool BaseSurface::prepareToDraw() { if (!_valid) {
//_gameRef->LOG(0, "Reviving: %s", _filename);
return create(_filename.c_str(), _ckDefault, _ckRed, _ckGreen, _ckBlue, _lifeTime, _keepLoaded);
- } else return STATUS_OK;
+ } else {
+ return STATUS_OK;
+ }
}
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 43cf66d053..e465194e58 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -44,10 +44,12 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(true) {
_colorMod = 0;
_mirror = TransparentSurface::FLIP_NONE;
- if (mirrorX)
+ if (mirrorX) {
_mirror |= TransparentSurface::FLIP_V;
- if (mirrorY)
+ }
+ if (mirrorY) {
_mirror |= TransparentSurface::FLIP_H;
+ }
if (surf) {
_surface = new Graphics::Surface();
_surface->create((uint16)srcRect->width(), (uint16)srcRect->height(), surf->format);
@@ -113,8 +115,12 @@ BaseRenderOSystem::~BaseRenderOSystem() { _renderSurface->free();
delete _renderSurface;
#if 0
- if (_renderer) SDL_DestroyRenderer(_renderer);
- if (_win) SDL_DestroyWindow(_win);
+ if (_renderer) {
+ SDL_DestroyRenderer(_renderer);
+ }
+ if (_win) {
+ SDL_DestroyWindow(_win);
+ }
SDL_Quit();
#endif
}
@@ -212,7 +218,9 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { _realWidth, _realHeight,
flags);
- if (!_win) return STATUS_FAILED;
+ if (!_win) {
+ return STATUS_FAILED;
+ }
#endif
g_system->showMouse(false);
@@ -226,7 +234,9 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { #if 0
_renderer = SDL_CreateRenderer(_win, -1, 0);
- if (!_renderer) return STATUS_FAILED;
+ if (!_renderer) {
+ return STATUS_FAILED;
+ }
#endif
_renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat());
_active = true;
@@ -273,8 +283,9 @@ bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF);
//SDL_RenderClear(_renderer);
_clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b);
- if (!_disableDirtyRects)
+ if (!_disableDirtyRects) {
return STATUS_OK;
+ }
if (!rect) {
rect = &_renderRect;
}
@@ -320,9 +331,9 @@ void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect //TODO: This is only here until I'm sure about the final pixelformat
uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b);
- if (_disableDirtyRects)
+ if (_disableDirtyRects) {
_renderSurface->fillRect(fillRect, col);
- else {
+ } else {
setAlphaMod(a);
setColorMod(r, g, b);
Graphics::Surface surf;
@@ -468,8 +479,9 @@ void BaseRenderOSystem::drawTickets() { it++;
}
}
- if (!_dirtyRect || _dirtyRect->width() == 0 || _dirtyRect->height() == 0)
+ if (!_dirtyRect || _dirtyRect->width() == 0 || _dirtyRect->height() == 0) {
return;
+ }
// The color-mods are stored in the RenderTickets on add, since we set that state again during
// draw, we need to keep track of what it was prior to draw.
uint32 oldColorMod = _colorMod;
@@ -518,8 +530,9 @@ void BaseRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::R }
src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, clipRect, _colorMod, clipRect->width(), clipRect->height());
- if (doDelete)
+ if (doDelete) {
delete clipRect;
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -566,9 +579,13 @@ BaseImage *BaseRenderOSystem::takeScreenshot() { SDL_RenderGetViewport(_renderer, &viewport);
SDL_Surface *surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, 0x00000000);
- if (!surface) return NULL;
+ if (!surface) {
+ return NULL;
+ }
- if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) return NULL;
+ if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) {
+ return NULL;
+ }
FIBITMAP *dib = FreeImage_Allocate(viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK);
@@ -643,7 +660,9 @@ void BaseRenderOSystem::dumpData(const char *filename) { warning("BaseRenderOSystem::DumpData(%s) - not reimplemented yet", filename); // TODO
#if 0
FILE *f = fopen(filename, "wt");
- if (!f) return;
+ if (!f) {
+ return;
+ }
BaseSurfaceStorage *Mgr = _gameRef->_surfaceStorage;
@@ -652,8 +671,12 @@ void BaseRenderOSystem::dumpData(const char *filename) { fprintf(f, "Filename;Usage;Size;KBytes\n");
for (int i = 0; i < Mgr->_surfaces.getSize(); i++) {
BaseSurfaceOSystem *Surf = (BaseSurfaceOSystem *)Mgr->_surfaces[i];
- if (!Surf->_filename) continue;
- if (!Surf->_valid) continue;
+ if (!Surf->_filename) {
+ continue;
+ }
+ if (!Surf->_valid) {
+ continue;
+ }
fprintf(f, "%s;%d;", Surf->_filename, Surf->_referenceCount);
fprintf(f, "%dx%d;", Surf->getWidth(), Surf->getHeight());
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 36213dfde1..4b680e2793 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -107,11 +107,14 @@ bool BaseSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed _ckGreen = ckGreen;
_ckBlue = ckBlue;
- if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime)
+ if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime) {
_lifeTime = lifeTime;
+ }
_keepLoaded = keepLoaded;
- if (_keepLoaded) _lifeTime = -1;
+ if (_keepLoaded) {
+ _lifeTime = -1;
+ }
return STATUS_OK;
}
@@ -201,7 +204,9 @@ void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { delete[] _alphaMask;
_alphaMask = NULL;
- if (!surface) return;
+ if (!surface) {
+ return;
+ }
#if 0
SDL_LockSurface(surface);
#endif
@@ -224,11 +229,14 @@ void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { surface->format.colorToARGB(pixel, a, r, g, b);
//SDL_GetRGBA(pixel, surface->format, &r, &g, &b, &a);
- if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue)
+ if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) {
a = 0;
+ }
_alphaMask[y * surface->w + x] = a;
- if (a < 255) hasTransparency = true;
+ if (a < 255) {
+ hasTransparency = true;
+ }
}
}
#if 0
@@ -331,7 +339,9 @@ bool BaseSurfaceOSystem::isTransparentAt(int x, int y) { int width, height;
//SDL_QueryTexture(_texture, NULL, &access, &width, &height); //TODO
//if (access != SDL_TEXTUREACCESS_STREAMING) return false;
- if (X < 0 || X >= width || Y < 0 || Y >= height) return true;
+ if (X < 0 || X >= width || Y < 0 || Y >= height) {
+ return true;
+ }
StartPixelOp();
@@ -371,10 +381,15 @@ bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) { //SDL_QueryTexture(_texture, &format, &access, &width, &height);
//if (access != SDL_TEXTUREACCESS_STREAMING) return false;
- if (X < 0 || X >= width || Y < 0 || Y >= height) return true;
+ if (X < 0 || X >= width || Y < 0 || Y >= height) {
+ return true;
+ }
- if (!_alphaMask) return false;
- else return _alphaMask[Y * width + X] <= 128;
+ if (!_alphaMask) {
+ return false;
+ } else {
+ return _alphaMask[Y * width + X] <= 128;
+ }
#endif
return false;
/*
@@ -447,8 +462,9 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo finishLoad();
}
- if (renderer->_forceAlphaColor != 0)
+ if (renderer->_forceAlphaColor != 0) {
alpha = renderer->_forceAlphaColor;
+ }
// This particular warning is rather messy, as this function is called a ton,
// thus we avoid printing it more than once.
@@ -469,10 +485,11 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo SDL_SetTextureColorMod(_texture, r, g, b);
SDL_SetTextureAlphaMod(_texture, a);
- if (AlphaDisable)
+ if (alphaDisable) {
SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE);
- else
+ } else {
SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_BLEND);
+ }
#endif
// TODO: This _might_ miss the intended behaviour by 1 in each direction
// But I think it fits the model used in Wintermute.
|