Compilation fixes. Sorry about the mess.

svn-id: r32272
This commit is contained in:
Vicent Marti 2008-05-25 17:06:10 +00:00
parent ca51f1f247
commit 862a3d575a
4 changed files with 71 additions and 70 deletions

View file

@ -65,13 +65,13 @@ void vector_renderer_test(OSystem *_system) {
vr->setFgColor(255, 0, 206); vr->setFgColor(255, 0, 206);
vr->setGradientFactor(1); vr->setGradientFactor(1);
vr->setGradientColors(214, 113, 8, 240, 200, 25); vr->setGradientColors(214, 113, 8, 240, 200, 25);
vr->fillSurface(VectorRenderer::kGradientFill); vr->fillSurface(kFillMode_Gradient);
vr->setBgColor(25, 25, 175); vr->setBgColor(25, 25, 175);
vr->shadowEnable(3); vr->shadowEnable(3);
vr->setFgColor(240, 204, 120); vr->setFgColor(240, 204, 120);
vr->setStrokeWidth(1); vr->setStrokeWidth(1);
vr->setFillMode(VectorRenderer::kGradientFill); vr->setFillMode(kFillMode_Gradient);
vr->setGradientFactor(3); vr->setGradientFactor(3);
vr->setGradientColors(255, 231, 140, 255, 243, 206); vr->setGradientColors(255, 231, 140, 255, 243, 206);
@ -240,33 +240,33 @@ 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)
return; return;
if (Base::_fillMode != kNoFill && Base::_shadowOffset if (Base::_fillMode != kFillMode_Disabled && Base::_shadowOffset
&& x + r + Base::_shadowOffset < Base::_activeSurface->w && x + r + Base::_shadowOffset < Base::_activeSurface->w
&& y + r + Base::_shadowOffset < Base::_activeSurface->h) { && y + r + Base::_shadowOffset < Base::_activeSurface->h) {
drawCircleAlg(x + Base::_shadowOffset + 1, y + Base::_shadowOffset + 1, r, 0, kForegroundFill); drawCircleAlg(x + Base::_shadowOffset + 1, y + Base::_shadowOffset + 1, r, 0, kFillMode_Foreground);
} }
switch(Base::_fillMode) { switch(Base::_fillMode) {
case kNoFill: case kFillMode_Disabled:
if (Base::_strokeWidth) if (Base::_strokeWidth)
drawCircleAlg(x, y, r, _fgColor, kNoFill); drawCircleAlg(x, y, r, _fgColor, kFillMode_Disabled);
break; break;
case kForegroundFill: case kFillMode_Foreground:
drawCircleAlg(x, y, r, _fgColor, kForegroundFill); drawCircleAlg(x, y, r, _fgColor, kFillMode_Foreground);
break; break;
case kBackgroundFill: case kFillMode_Background:
if (Base::_strokeWidth > 1) { if (Base::_strokeWidth > 1) {
drawCircleAlg(x, y, r, _fgColor, kForegroundFill); drawCircleAlg(x, y, r, _fgColor, kFillMode_Foreground);
drawCircleAlg(x, y, r - Base::_strokeWidth, _bgColor, kBackgroundFill); drawCircleAlg(x, y, r - Base::_strokeWidth, _bgColor, kFillMode_Background);
} else { } else {
drawCircleAlg(x, y, r, _bgColor, kBackgroundFill); drawCircleAlg(x, y, r, _bgColor, kFillMode_Background);
drawCircleAlg(x, y, r, _fgColor, kNoFill); drawCircleAlg(x, y, r, _fgColor, kFillMode_Disabled);
} }
break; break;
case kGradientFill: case kFillMode_Gradient:
break; break;
} }
} }
@ -278,31 +278,31 @@ 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)
return; return;
if (Base::_fillMode != kNoFill && Base::_shadowOffset if (Base::_fillMode != kFillMode_Disabled && Base::_shadowOffset
&& x + w + Base::_shadowOffset < Base::_activeSurface->w && x + w + Base::_shadowOffset < Base::_activeSurface->w
&& y + h + Base::_shadowOffset < Base::_activeSurface->h) { && y + h + Base::_shadowOffset < Base::_activeSurface->h) {
drawSquareShadow(x, y, w, h, Base::_shadowOffset); drawSquareShadow(x, y, w, h, Base::_shadowOffset);
} }
switch(Base::_fillMode) { switch(Base::_fillMode) {
case kNoFill: case kFillMode_Disabled:
if (Base::_strokeWidth) if (Base::_strokeWidth)
drawSquareAlg(x, y, w, h, _fgColor, kNoFill); drawSquareAlg(x, y, w, h, _fgColor, kFillMode_Disabled);
break; break;
case kForegroundFill: case kFillMode_Foreground:
drawSquareAlg(x, y, w, h, _fgColor, kForegroundFill); drawSquareAlg(x, y, w, h, _fgColor, kFillMode_Foreground);
break; break;
case kBackgroundFill: case kFillMode_Background:
drawSquareAlg(x, y, w, h, _bgColor, kBackgroundFill); drawSquareAlg(x, y, w, h, _bgColor, kFillMode_Background);
drawSquareAlg(x, y, w, h, _fgColor, kNoFill); drawSquareAlg(x, y, w, h, _fgColor, kFillMode_Disabled);
break; break;
case kGradientFill: case kFillMode_Gradient:
VectorRendererSpec::drawSquareAlg(x, y, w, h, 0, kGradientFill); VectorRendererSpec::drawSquareAlg(x, y, w, h, 0, kFillMode_Gradient);
if (Base::_strokeWidth) if (Base::_strokeWidth)
drawSquareAlg(x, y, w, h, _fgColor, kNoFill); drawSquareAlg(x, y, w, h, _fgColor, kFillMode_Disabled);
break; break;
} }
} }
@ -314,36 +314,36 @@ 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)
return; return;
if (Base::_fillMode != kNoFill && Base::_shadowOffset if (Base::_fillMode != kFillMode_Disabled && Base::_shadowOffset
&& x + w + Base::_shadowOffset < Base::_activeSurface->w && x + w + Base::_shadowOffset < Base::_activeSurface->w
&& y + h + Base::_shadowOffset < Base::_activeSurface->h) { && y + h + Base::_shadowOffset < Base::_activeSurface->h) {
drawRoundedSquareShadow(x, y, r, w, h, Base::_shadowOffset); drawRoundedSquareShadow(x, y, r, w, h, Base::_shadowOffset);
} }
switch(Base::_fillMode) { switch(Base::_fillMode) {
case kNoFill: case kFillMode_Disabled:
if (Base::_strokeWidth) if (Base::_strokeWidth)
drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kNoFill); drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillMode_Disabled);
break; break;
case kForegroundFill: case kFillMode_Foreground:
drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kForegroundFill); drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillMode_Foreground);
break; break;
case kBackgroundFill: case kFillMode_Background:
VectorRendererSpec::drawRoundedSquareAlg(x, y, r, w, h, _bgColor, kBackgroundFill); VectorRendererSpec::drawRoundedSquareAlg(x, y, r, w, h, _bgColor, kFillMode_Background);
drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kNoFill); drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillMode_Disabled);
break; break;
case kGradientFill: case kFillMode_Gradient:
if (Base::_strokeWidth > 1) { if (Base::_strokeWidth > 1) {
drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kForegroundFill); drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillMode_Foreground);
VectorRendererSpec::drawRoundedSquareAlg(x + Base::_strokeWidth/2, y + Base::_strokeWidth/2, VectorRendererSpec::drawRoundedSquareAlg(x + Base::_strokeWidth/2, y + Base::_strokeWidth/2,
r - Base::_strokeWidth/2, w - Base::_strokeWidth, h - Base::_strokeWidth, 0, kGradientFill); r - Base::_strokeWidth/2, w - Base::_strokeWidth, h - Base::_strokeWidth, 0, kFillMode_Gradient);
} else { } else {
VectorRendererSpec::drawRoundedSquareAlg(x, y, r, w, h, 0, kGradientFill); VectorRendererSpec::drawRoundedSquareAlg(x, y, r, w, h, 0, kFillMode_Gradient);
if (Base::_strokeWidth) if (Base::_strokeWidth)
drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kNoFill); drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillMode_Disabled);
} }
break; break;
} }
@ -360,9 +360,9 @@ drawSquareAlg(int x, int y, int w, int h, PixelType color, FillMode fill_m) {
int pitch = Base::surfacePitch(); int pitch = Base::surfacePitch();
int max_h = h; int max_h = h;
if (fill_m != kNoFill) { if (fill_m != kFillMode_Disabled) {
while (h--) { while (h--) {
if (fill_m == kGradientFill) if (fill_m == kFillMode_Gradient)
color = calcGradient(max_h - h, max_h); color = calcGradient(max_h - h, max_h);
colorFill(ptr, ptr + w, color); colorFill(ptr, ptr + w, color);
@ -452,7 +452,7 @@ drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, FillM
int short_h = h - (2 * r) + 2; int short_h = h - (2 * r) + 2;
int long_h = h; int long_h = h;
if (fill_m == kNoFill) { if (fill_m == kFillMode_Disabled) {
while (sw++ < Base::_strokeWidth) { while (sw++ < Base::_strokeWidth) {
colorFill(ptr_fill + sp + r, ptr_fill + w + 1 + sp - r, color); colorFill(ptr_fill + sp + r, ptr_fill + w + 1 + sp - r, color);
colorFill(ptr_fill + hp - sp + r, ptr_fill + w + hp + 1 - sp - r, color); colorFill(ptr_fill + hp - sp + r, ptr_fill + w + hp + 1 - sp - r, color);
@ -481,7 +481,7 @@ drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, FillM
} else { } else {
__BE_RESET(); __BE_RESET();
if (fill_m == kGradientFill) { if (fill_m == kFillMode_Gradient) {
while (x++ < y) { while (x++ < y) {
__BE_ALGORITHM(); __BE_ALGORITHM();
colorFill(ptr_tl - x - py, ptr_tr + x - py, calcGradient(real_radius - y, long_h)); colorFill(ptr_tl - x - py, ptr_tr + x - py, calcGradient(real_radius - y, long_h));
@ -507,7 +507,7 @@ drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, FillM
ptr_fill += pitch * r; ptr_fill += pitch * r;
while (short_h--) { while (short_h--) {
if (fill_m == kGradientFill) if (fill_m == kFillMode_Gradient)
color = calcGradient(real_radius++, long_h); color = calcGradient(real_radius++, long_h);
colorFill(ptr_fill, ptr_fill + w + 1, color); colorFill(ptr_fill, ptr_fill + w + 1, color);
ptr_fill += pitch; ptr_fill += pitch;
@ -524,7 +524,7 @@ drawCircleAlg(int x1, int y1, int r, PixelType color, FillMode fill_m) {
int pitch = Base::surfacePitch(); int pitch = Base::surfacePitch();
PixelType *ptr = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1); PixelType *ptr = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1);
if (fill_m == kNoFill) { if (fill_m == kFillMode_Disabled) {
while (sw++ < Base::_strokeWidth) { while (sw++ < Base::_strokeWidth) {
__BE_RESET(); __BE_RESET();
r--; r--;
@ -711,7 +711,7 @@ drawLineAlg(int x1, int y1, int x2, int y2, int dx, int dy, PixelType color) {
/** ROUNDED SQUARES **/ /** ROUNDED SQUARES **/
template<typename PixelType, typename PixelFormat> template<typename PixelType, typename PixelFormat>
void VectorRendererAA<PixelType, PixelFormat>:: void VectorRendererAA<PixelType, PixelFormat>::
drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) { drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, FillMode fill_m) {
int x, y; int x, y;
int p = Base::surfacePitch(), px, py; int p = Base::surfacePitch(), px, py;
int sw = 0, sp = 0, hp = h * p; int sw = 0, sp = 0, hp = h * p;
@ -728,7 +728,7 @@ drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, Vecto
int short_h = h - 2 * r; int short_h = h - 2 * r;
if (fill_m == VectorRenderer::kNoFill) { if (fill_m == kFillMode_Disabled) {
while (sw++ < Base::_strokeWidth) { while (sw++ < Base::_strokeWidth) {
colorFill(ptr_fill + sp + r, ptr_fill + w + 1 + sp - r, color); colorFill(ptr_fill + sp + r, ptr_fill + w + 1 + sp - r, color);
colorFill(ptr_fill + hp - sp + r, ptr_fill + w + hp + 1 - sp - r, color); colorFill(ptr_fill + hp - sp + r, ptr_fill + w + hp + 1 - sp - r, color);
@ -781,7 +781,7 @@ drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, Vecto
/** CIRCLES **/ /** CIRCLES **/
template<typename PixelType, typename PixelFormat> template<typename PixelType, typename PixelFormat>
void VectorRendererAA<PixelType, PixelFormat>:: void VectorRendererAA<PixelType, PixelFormat>::
drawCircleAlg(int x1, int y1, int r, PixelType color, VectorRenderer::FillMode fill_m) { drawCircleAlg(int x1, int y1, int r, PixelType color, FillMode fill_m) {
int x, y, sw = 0; int x, y, sw = 0;
int p = Base::surfacePitch(), px, py; int p = Base::surfacePitch(), px, py;
@ -791,7 +791,7 @@ drawCircleAlg(int x1, int y1, int r, PixelType color, VectorRenderer::FillMode f
PixelType *ptr = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1); PixelType *ptr = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1);
if (fill_m == VectorRenderer::kNoFill) { if (fill_m == kFillMode_Disabled) {
while (sw++ < Base::_strokeWidth) { while (sw++ < Base::_strokeWidth) {
x = r - (sw - 1); y = 0; T = 0; x = r - (sw - 1); y = 0; T = 0;
px = p * x; py = 0; px = p * x; py = 0;

View file

@ -35,6 +35,14 @@ namespace Graphics {
void vector_renderer_test(OSystem *_system); void vector_renderer_test(OSystem *_system);
/** Specified the way in which a shape is filled */
enum FillMode {
kFillMode_Disabled = 0,
kFillMode_Foreground = 1,
kFillMode_Background = 2,
kFillMode_Gradient = 3
};
struct DrawStep { struct DrawStep {
bool set_fg, set_bg, set_grad; bool set_fg, set_bg, set_grad;
@ -47,7 +55,7 @@ struct DrawStep {
uint16 x, y, w, h, r; uint16 x, y, w, h, r;
uint8 shadows, stroke, factor; uint8 shadows, stroke, factor;
Graphics::VectorRenderer::FillMode fill_mode; FillMode fill_mode;
void (*drawing_call)(DrawStep *step); void (*drawing_call)(DrawStep *step);
}; };
@ -70,17 +78,9 @@ struct DrawStep {
*/ */
class VectorRenderer { class VectorRenderer {
public: public:
VectorRenderer() : _shadowOffset(0), _fillMode(kNoFill), _activeSurface(NULL), _strokeWidth(1), _gradientFactor(1) {} VectorRenderer() : _shadowOffset(0), _fillMode(kFillMode_Disabled), _activeSurface(NULL), _strokeWidth(1), _gradientFactor(1) {}
virtual ~VectorRenderer() {} virtual ~VectorRenderer() {}
/** Specified the way in which a shape is filled */
enum FillMode {
kNoFill = 0,
kForegroundFill = 1,
kBackgroundFill = 2,
kGradientFill = 3
};
/** /**
* Draws a line by considering the special cases for optimization. * Draws a line by considering the special cases for optimization.
* *
@ -171,7 +171,7 @@ public:
virtual void setBgColor(uint8 r, uint8 g, uint8 b) = 0; virtual void setBgColor(uint8 r, uint8 g, uint8 b) = 0;
/** /**
* Set the active gradient color. All shapes drawn using kGradientFill * Set the active gradient color. All shapes drawn using kFillMode_Gradient
* as their fill mode will use this VERTICAL gradient as their fill color. * as their fill mode will use this VERTICAL gradient as their fill color.
* *
* @param r1 value of the red color byte for the start color * @param r1 value of the red color byte for the start color
@ -199,7 +199,7 @@ public:
* *
* @param mode Fill mode (bg, fg or gradient) used to fill the surface * @param mode Fill mode (bg, fg or gradient) used to fill the surface
*/ */
virtual void fillSurface(FillMode mode = kForegroundFill) = 0; virtual void fillSurface(FillMode mode = kFillMode_Foreground) = 0;
/** /**
* Clears the active surface. * Clears the active surface.
@ -215,7 +215,7 @@ public:
* @see VectorRenderer::FillMode * @see VectorRenderer::FillMode
* @param mode Specified fill mode. * @param mode Specified fill mode.
*/ */
virtual void setFillMode(VectorRenderer::FillMode mode) { virtual void setFillMode(FillMode mode) {
_fillMode = mode; _fillMode = mode;
} }
@ -370,18 +370,18 @@ public:
/** /**
* @see VectorRenderer::fillSurface() * @see VectorRenderer::fillSurface()
*/ */
void fillSurface(FillMode mode = kForegroundFill) { void fillSurface(FillMode mode = kFillMode_Foreground) {
PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(0, 0); PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(0, 0);
int w = _activeSurface->w; int w = _activeSurface->w;
int h = _activeSurface->h ; int h = _activeSurface->h ;
int pitch = surfacePitch(); int pitch = surfacePitch();
if (mode == kBackgroundFill) if (mode == kFillMode_Background)
colorFill(ptr, ptr + w * h, _bgColor); colorFill(ptr, ptr + w * h, _bgColor);
else if (mode == kForegroundFill) else if (mode == kFillMode_Foreground)
colorFill(ptr, ptr + w * h, _fgColor); colorFill(ptr, ptr + w * h, _fgColor);
else if (mode == kGradientFill) { else if (mode == kFillMode_Gradient) {
int i = h; int i = h;
while (i--) { while (i--) {
colorFill(ptr, ptr + w, calcGradient(h - i, h)); colorFill(ptr, ptr + w, calcGradient(h - i, h));
@ -596,7 +596,7 @@ protected:
* *
* @see VectorRenderer::drawCircleAlg() * @see VectorRenderer::drawCircleAlg()
*/ */
virtual void drawCircleAlg(int x, int y, int r, PixelType color, VectorRenderer::FillMode fill_m); virtual void drawCircleAlg(int x, int y, int r, PixelType color, FillMode fill_m);
/** /**
* "Wu's Circle Antialiasing Algorithm" as published by Xiaolin Wu, July 1991, * "Wu's Circle Antialiasing Algorithm" as published by Xiaolin Wu, July 1991,
@ -605,7 +605,7 @@ protected:
* *
* @see VectorRenderer::drawRoundedAlg() * @see VectorRenderer::drawRoundedAlg()
*/ */
virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m); virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, FillMode fill_m);
}; };
} // end of namespace Graphics } // end of namespace Graphics

View file

@ -36,4 +36,4 @@ namespace GUI {
} // end of namespace GUI. } // end of namespace GUI.

View file

@ -29,6 +29,7 @@
#include "common/scummsys.h" #include "common/scummsys.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "common/system.h" #include "common/system.h"
#include "graphics/VectorRenderer.h" #include "graphics/VectorRenderer.h"
namespace GUI { namespace GUI {
@ -48,7 +49,7 @@ protected:
Graphics::VectorRenderer *createRenderer() { Graphics::VectorRenderer *createRenderer() {
// TODO: Find out what pixel format we are using, // TODO: Find out what pixel format we are using,
// create the renderer accordingly // create the renderer accordingly
return new VectorRendererSpec<uint16, ColorMasks<565> >; return new Graphics::VectorRendererSpec<uint16, ColorMasks<565> >;
} }
Graphics::VectorRenderer *_vectorRenderer; Graphics::VectorRenderer *_vectorRenderer;
@ -56,4 +57,4 @@ protected:
} // end of namespace GUI. } // end of namespace GUI.
#endif #endif