aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorVicent Marti2008-06-10 11:25:00 +0000
committerVicent Marti2008-06-10 11:25:00 +0000
commit29c4308c420722088f47b5724d176a3c2e4ef290 (patch)
tree945880b6859e9b38585ca40d95690e110a62543a /graphics
parentda757aa2ca1c086ae2f123dc6636d17655b512c7 (diff)
downloadscummvm-rg350-29c4308c420722088f47b5724d176a3c2e4ef290.tar.gz
scummvm-rg350-29c4308c420722088f47b5724d176a3c2e4ef290.tar.bz2
scummvm-rg350-29c4308c420722088f47b5724d176a3c2e4ef290.zip
Changed DrawStep for dynamic surface drawing.
svn-id: r32643
Diffstat (limited to 'graphics')
-rw-r--r--graphics/VectorRenderer.cpp15
-rw-r--r--graphics/VectorRenderer.h61
2 files changed, 27 insertions, 49 deletions
diff --git a/graphics/VectorRenderer.cpp b/graphics/VectorRenderer.cpp
index 43046bafdf..109ae24f03 100644
--- a/graphics/VectorRenderer.cpp
+++ b/graphics/VectorRenderer.cpp
@@ -51,10 +51,10 @@ VectorRenderer *createRenderer(int mode) {
/********************************************************************
* DRAWSTEP handling functions
********************************************************************/
-void VectorRenderer::drawStep(DrawStep *step) {
+void VectorRenderer::drawStep(Common::Rect area, DrawStep *step) {
if (step->flags & DrawStep::kStepCallbackOnly) {
- (this->*(step->drawing_call))(step);
+ (this->*(step->drawing_call))(&area, step->extra_data);
return;
}
@@ -83,7 +83,7 @@ void VectorRenderer::drawStep(DrawStep *step) {
if (step->flags & DrawStep::kStepSettingsOnly)
return;
- (this->*(step->drawing_call))(step);
+ (this->*(step->drawing_call))(&area, step->extra_data);
}
/********************************************************************
@@ -248,7 +248,8 @@ drawLine(int x1, int y1, int x2, int y2) {
template<typename PixelType, typename PixelFormat>
void VectorRendererSpec<PixelType, PixelFormat>::
drawCircle(int x, int y, int r) {
- if (x + r > Base::_activeSurface->w || y + r > Base::_activeSurface->h)
+ if (x + r > Base::_activeSurface->w || y + r > Base::_activeSurface->h ||
+ x - r < 0 || y - r < 0 || x == 0 || y == 0 || r <= 0)
return;
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
@@ -286,7 +287,8 @@ drawCircle(int x, int y, int r) {
template<typename PixelType, typename PixelFormat>
void VectorRendererSpec<PixelType, PixelFormat>::
drawSquare(int x, int y, int w, int h) {
- if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h)
+ if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h ||
+ w <= 0 || h <= 0 || x < 0 || y < 0)
return;
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
@@ -322,7 +324,8 @@ drawSquare(int x, int y, int w, int h) {
template<typename PixelType, typename PixelFormat>
void VectorRendererSpec<PixelType, PixelFormat>::
drawRoundedSquare(int x, int y, int r, int w, int h) {
- if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h)
+ if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h ||
+ w <= 0 || h <= 0 || x < 0 || y < 0 || r <= 0 || r > 128)
return;
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h
index 2226907670..9958714df6 100644
--- a/graphics/VectorRenderer.h
+++ b/graphics/VectorRenderer.h
@@ -47,14 +47,12 @@ struct DrawStep {
color1, /** Foreground color/gradient start */
color2; /** Background color/gradient end */
- uint16 x, y, w, h, r; /** Shape size */
- uint16 offset_x, offset_y; /** Offset when drawing directly to the whole screen */
uint8 shadow, stroke, factor; /** Misc options... */
int fill_mode; /** active fill mode */
- int extra; /** Generic parameter for extra options */
+ int extra_data; /** Generic parameter for extra options (radius/orientation/bevel) */
- void (VectorRenderer::*drawing_call)(DrawStep*); /** Pointer to drawing function */
+ void (VectorRenderer::*drawing_call)(Common::Rect*, int); /** Pointer to drawing function */
enum DrawStepFlags {
kStepCallbackOnly = (1 << 0),
@@ -89,8 +87,7 @@ VectorRenderer *createRenderer(int mode);
class VectorRenderer {
public:
VectorRenderer() : _shadowOffset(0), _fillMode(kFillDisabled),
- _activeSurface(NULL), _strokeWidth(1), _gradientFactor(1),
- _stepOffsetX(0), _stepOffsetY(0) {
+ _activeSurface(NULL), _strokeWidth(1), _gradientFactor(1) {
}
@@ -322,41 +319,42 @@ public:
/**
* DrawStep callback functions for each drawing feature
*/
- void drawCallback_CIRCLE(DrawStep *step) {
- drawCircle(_stepOffsetX + step->x, _stepOffsetY + step->y, step->r);
+ void drawCallback_CIRCLE(Common::Rect *area, int data) {
+ drawCircle(area->left + data, area->top + data, data);
}
- void drawCallback_SQUARE(DrawStep *step) {
- drawSquare(_stepOffsetX + step->x, _stepOffsetY + step->y, step->w, step->h);
+ void drawCallback_SQUARE(Common::Rect *area, int data) {
+ drawSquare(area->left, area->top, area->width(), area->height());
}
- void drawCallback_LINE(DrawStep *step) {
- drawLine(_stepOffsetX + step->x, _stepOffsetY + step->y, step->x + step->w, step->y + step->h);
+ void drawCallback_LINE(Common::Rect *area, int data) {
+ drawLine(area->left, area->top, area->right, area->bottom);
}
- void drawCallback_ROUNDSQ(DrawStep *step) {
- drawRoundedSquare(_stepOffsetX + step->x, _stepOffsetY + step->y, step->r, step->w, step->h);
+ void drawCallback_ROUNDSQ(Common::Rect *area, int data) {
+ drawRoundedSquare(area->left, area->top, data, area->width(), area->height());
}
- void drawCallback_FILLSURFACE(DrawStep *step) {
+ void drawCallback_FILLSURFACE(Common::Rect *area, int data) {
fillSurface();
}
- void drawCallback_TRIANGLE(DrawStep *step) {
- drawTriangle(_stepOffsetX + step->x, _stepOffsetY + step->y, step->w, step->h, (TriangleOrientation)step->extra);
+ void drawCallback_TRIANGLE(Common::Rect *area, int data) {
+ drawTriangle(area->top, area->left, area->width(), area->height(), (TriangleOrientation)data);
}
- void drawCallback_BEVELSQ(DrawStep *step) {
- drawBeveledSquare(_stepOffsetX + step->x, _stepOffsetY + step->y, step->w, step->h, step->extra);
+ void drawCallback_BEVELSQ(Common::Rect *area, int data) {
+ drawBeveledSquare(area->left, area->top, area->width(), area->height(), data);
}
/**
* Draws the specified draw step on the screen.
*
* @see DrawStep
+ * @param area Zone to paint on
* @param step Pointer to a DrawStep struct.
*/
- virtual void drawStep(DrawStep *step);
+ virtual void drawStep(Common::Rect area, DrawStep *step);
/**
* Copies the current surface to the system overlay
@@ -365,32 +363,9 @@ public:
*/
virtual void copyFrame(OSystem *sys) = 0;
- /**
- * Enables drawing offset for all the Draw Step operations,
- * i.e. when we are drawing widgets directly on a whole screen
- * instead of individual surfaces for caching/blitting.
- *
- * @param x Horizontal drawing offset.
- * @param y Veritcal drawing offset.
- */
- void setDrawOffset(int x, int y) {
- _stepOffsetX = x;
- _stepOffsetY = y;
- }
-
- /**
- * Disables the drawing offset for draw step operations.
- */
- void disableDrawOffset() {
- _stepOffsetX = _stepOffsetY = 0;
- }
-
protected:
Surface *_activeSurface; /** Pointer to the surface currently being drawn */
- int _stepOffsetX; /** Offset for all the drawing steps */
- int _stepOffsetY; /** Offset for all the drawing steps */
-
FillMode _fillMode; /** Defines in which way (if any) are filled the drawn shapes */
int _shadowOffset; /** offset for drawn shadows */