aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/base/gfx/osystem
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-07-26 15:59:26 +0200
committerEinar Johan Trøan Sømåen2012-07-26 15:59:26 +0200
commitef11f9d0c53cbdd9d88a99143de6f43f34d7e24d (patch)
tree8dfaee0ba16e18a8e3772dd5afc9123d5c4e78d2 /engines/wintermute/base/gfx/osystem
parent38507fa9895620639d8733dbb4e085dfb2282a33 (diff)
downloadscummvm-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/osystem')
-rw-r--r--engines/wintermute/base/gfx/osystem/base_render_osystem.cpp55
-rw-r--r--engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp41
2 files changed, 68 insertions, 28 deletions
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.