summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-03-26 14:48:19 +0200
committerAndrei Karas <akaras@inbox.ru>2011-03-26 14:48:19 +0200
commit0a62226b1cc9c1b01ddab4feb9095ed7a5ba3e48 (patch)
tree7e0611c09922dee95259c23ac02df14530be45a3 /src
parent8403dcf857c9cc639e8162edd5d4df4af07274bc (diff)
downloadmv-0a62226b1cc9c1b01ddab4feb9095ed7a5ba3e48.tar.gz
mv-0a62226b1cc9c1b01ddab4feb9095ed7a5ba3e48.tar.bz2
mv-0a62226b1cc9c1b01ddab4feb9095ed7a5ba3e48.tar.xz
mv-0a62226b1cc9c1b01ddab4feb9095ed7a5ba3e48.zip
Remove debug code and add checks in graphics classes.
Diffstat (limited to 'src')
-rw-r--r--src/graphics.cpp55
-rw-r--r--src/graphics.h2
-rw-r--r--src/opengl1graphics.cpp6
3 files changed, 14 insertions, 49 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index e221f9fdb..c1d96acdd 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -269,53 +269,6 @@ void Graphics::drawImagePattern(Image *image, int x, int y, int w, int h)
}
}
-void Graphics::drawImagePatternDebug(GraphicsVertexes* vert, Image *image, int x, int y, int w, int h)
-{
- // Check that preconditions for blitting are met.
- if (!mTarget || !image)
- return;
- if (!image->mSDLSurface)
- return;
-
- const int iw = image->getWidth();
- const int ih = image->getHeight();
-
- if (iw == 0 || ih == 0)
- return;
-
- std::list<DoubleRect*> *arr = vert->getRectsSDL();
- std::list<DoubleRect*>::iterator it;
- it = arr->begin();
-
- for (int py = 0; py < h; py += ih) // Y position on pattern plane
- {
- int dh = (py + ih >= h) ? h - py : ih;
- int srcY = image->mBounds.y;
- int dstY = y + py + mClipStack.top().yOffset;
-
- for (int px = 0; px < w; px += iw) // X position on pattern plane
- {
- int dw = (px + iw >= w) ? w - px : iw;
- int srcX = image->mBounds.x;
- int dstX = x + px + mClipStack.top().xOffset;
-
- SDL_Rect dstRect;
- SDL_Rect srcRect;
- dstRect.x = static_cast<short>(dstX);
- dstRect.y = static_cast<short>(dstY);
- srcRect.x = static_cast<short>(srcX);
- srcRect.y = static_cast<short>(srcY);
- srcRect.w = static_cast<Uint16>(dw);
- srcRect.h = static_cast<Uint16>(dh);
-
- SDL_BlitSurface(image->mSDLSurface, &srcRect, mTarget, &dstRect);
-
- ++it;
- }
- }
-}
-
-
void Graphics::drawRescaledImagePattern(Image *image, int x, int y,
int w, int h, int scaledWidth,
int scaledHeight)
@@ -434,6 +387,9 @@ void Graphics::drawImageRect(int x, int y, int w, int h,
void Graphics::drawImageRect2(GraphicsVertexes* vert, const ImageRect &imgRect)
{
+ if (!vert)
+ return;
+
vert->setPtr(0);
const bool drawMain = imgRect.grid[4] && imgRect.grid[0] && imgRect.grid[2]
@@ -476,6 +432,8 @@ void Graphics::drawImageRect2(GraphicsVertexes* vert, const ImageRect &imgRect)
void Graphics::drawImagePattern2(GraphicsVertexes *vert, Image *img)
{
+ // here not checking input parameters
+
std::list<DoubleRect*> *arr = vert->getRectsSDL();
std::list<DoubleRect*>::iterator it;
@@ -491,6 +449,9 @@ bool Graphics::calcImageRect(GraphicsVertexes* vert,
Image *bottom, Image *left,
Image *center)
{
+ if (!vert)
+ return false;
+
const bool drawMain = center && topLeft && topRight
&& bottomLeft && bottomRight;
diff --git a/src/graphics.h b/src/graphics.h
index 23ce0bb91..817249c60 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -164,8 +164,6 @@ class Graphics : public gcn::SDLGraphics
int x, int y,
int w, int h);
- void drawImagePatternDebug(GraphicsVertexes* vert, Image *image, int x, int y, int w, int h);
-
/**
* Draw a pattern based on a rescaled version of the given image...
*/
diff --git a/src/opengl1graphics.cpp b/src/opengl1graphics.cpp
index e1d44de23..4a1322e6d 100644
--- a/src/opengl1graphics.cpp
+++ b/src/opengl1graphics.cpp
@@ -404,12 +404,18 @@ bool OpenGL1Graphics::calcImageRect(GraphicsVertexes* vert,
Image *left _UNUSED_,
Image *center _UNUSED_)
{
+ if (!vert)
+ return false;
+
vert->init(x, y, w, h);
return true;
}
void OpenGL1Graphics::drawImageRect2(GraphicsVertexes* vert, const ImageRect &imgRect)
{
+ if (!vert)
+ return;
+
drawImageRect(vert->getX(), vert->getY(), vert->getW(), vert->getH(),
imgRect.grid[0], imgRect.grid[2], imgRect.grid[6], imgRect.grid[8],
imgRect.grid[1], imgRect.grid[5], imgRect.grid[7], imgRect.grid[3],