Misc fixes.

Constant naming fixes.

svn-id: r32342
This commit is contained in:
Vicent Marti 2008-05-28 15:03:30 +00:00
parent 74c458153e
commit 8a83eafbf3
5 changed files with 116 additions and 111 deletions

View file

@ -70,7 +70,7 @@ static bool launcherDialog(OSystem &system) {
#if 1
GUI::InterfaceManager iManager(&system, GUI::InterfaceManager::GFX_Standard_16bit);
GUI::InterfaceManager iManager(&system, GUI::InterfaceManager::kGfxStandard16bit);
iManager.runGUI();
return true;

View file

@ -37,14 +37,14 @@ namespace Graphics {
VectorRenderer *createRenderer(int mode) {
switch (mode) {
case GUI::InterfaceManager::GFX_Standard_16bit:
case GUI::InterfaceManager::kGfxStandard16bit:
return new VectorRendererSpec<uint16, ColorMasks<565> >;
case GUI::InterfaceManager::GFX_Antialias_16bit:
case GUI::InterfaceManager::kGfxAntialias16bit:
return new VectorRendererAA<uint16, ColorMasks<565> >;
default:
return NULL;
return 0;
}
}
@ -53,34 +53,34 @@ VectorRenderer *createRenderer(int mode) {
********************************************************************/
void VectorRenderer::drawStep(DrawStep *step) {
if (step->flags & kDrawStep_CallbackOnly) {
if (step->flags & DrawStep::kStepCallbackOnly) {
(this->*(step->drawing_call))(step);
return;
}
if (step->flags & kDrawStep_SetBG)
if (step->flags & DrawStep::kStepSetBG)
setBgColor(step->color2.r, step->color2.g, step->color2.b);
if (step->flags & kDrawStep_SetFG)
if (step->flags & DrawStep::kStepSetFG)
setFgColor(step->color1.r, step->color1.g, step->color1.b);
if (step->flags & kDrawStep_SetGradient)
if (step->flags & DrawStep::kStepSetGradient)
setGradientColors(step->color1.r, step->color1.g, step->color1.b,
step->color2.r, step->color2.g, step->color2.b);
if (step->flags & kDrawStep_SetShadow)
if (step->flags & DrawStep::kStepSetShadow)
shadowEnable(step->shadow);
if (step->flags & kDrawStep_SetGradientFactor)
if (step->flags & DrawStep::kStepSetGradientFactor)
setGradientFactor(step->factor);
if (step->flags & kDrawStep_SetStroke)
if (step->flags & DrawStep::kStepSetStroke)
setStrokeWidth(step->stroke);
if (step->flags & kDrawStep_SetFillMode)
setFillMode(step->fill_mode);
if (step->flags & DrawStep::kStepSetFillMode)
setFillMode((FillMode)step->fill_mode);
if (step->flags & kDrawStep_SettingsOnly)
if (step->flags & DrawStep::kStepSettingsOnly)
return;
(this->*(step->drawing_call))(step);
@ -229,33 +229,33 @@ drawCircle(int x, int y, int r) {
if (x + r > Base::_activeSurface->w || y + r > Base::_activeSurface->h)
return;
if (Base::_fillMode != kFillMode_Disabled && Base::_shadowOffset
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
&& x + r + Base::_shadowOffset < Base::_activeSurface->w
&& y + r + Base::_shadowOffset < Base::_activeSurface->h) {
drawCircleAlg(x + Base::_shadowOffset + 1, y + Base::_shadowOffset + 1, r, 0, kFillMode_Foreground);
drawCircleAlg(x + Base::_shadowOffset + 1, y + Base::_shadowOffset + 1, r, 0, kFillForeground);
}
switch(Base::_fillMode) {
case kFillMode_Disabled:
case kFillDisabled:
if (Base::_strokeWidth)
drawCircleAlg(x, y, r, _fgColor, kFillMode_Disabled);
drawCircleAlg(x, y, r, _fgColor, kFillDisabled);
break;
case kFillMode_Foreground:
drawCircleAlg(x, y, r, _fgColor, kFillMode_Foreground);
case kFillForeground:
drawCircleAlg(x, y, r, _fgColor, kFillForeground);
break;
case kFillMode_Background:
case kFillBackground:
if (Base::_strokeWidth > 1) {
drawCircleAlg(x, y, r, _fgColor, kFillMode_Foreground);
drawCircleAlg(x, y, r - Base::_strokeWidth, _bgColor, kFillMode_Background);
drawCircleAlg(x, y, r, _fgColor, kFillForeground);
drawCircleAlg(x, y, r - Base::_strokeWidth, _bgColor, kFillBackground);
} else {
drawCircleAlg(x, y, r, _bgColor, kFillMode_Background);
drawCircleAlg(x, y, r, _fgColor, kFillMode_Disabled);
drawCircleAlg(x, y, r, _bgColor, kFillBackground);
drawCircleAlg(x, y, r, _fgColor, kFillDisabled);
}
break;
case kFillMode_Gradient:
case kFillGradient:
break;
}
}
@ -267,31 +267,31 @@ drawSquare(int x, int y, int w, int h) {
if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h)
return;
if (Base::_fillMode != kFillMode_Disabled && Base::_shadowOffset
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
&& x + w + Base::_shadowOffset < Base::_activeSurface->w
&& y + h + Base::_shadowOffset < Base::_activeSurface->h) {
drawSquareShadow(x, y, w, h, Base::_shadowOffset);
}
switch(Base::_fillMode) {
case kFillMode_Disabled:
case kFillDisabled:
if (Base::_strokeWidth)
drawSquareAlg(x, y, w, h, _fgColor, kFillMode_Disabled);
drawSquareAlg(x, y, w, h, _fgColor, kFillDisabled);
break;
case kFillMode_Foreground:
drawSquareAlg(x, y, w, h, _fgColor, kFillMode_Foreground);
case kFillForeground:
drawSquareAlg(x, y, w, h, _fgColor, kFillForeground);
break;
case kFillMode_Background:
drawSquareAlg(x, y, w, h, _bgColor, kFillMode_Background);
drawSquareAlg(x, y, w, h, _fgColor, kFillMode_Disabled);
case kFillBackground:
drawSquareAlg(x, y, w, h, _bgColor, kFillBackground);
drawSquareAlg(x, y, w, h, _fgColor, kFillDisabled);
break;
case kFillMode_Gradient:
VectorRendererSpec::drawSquareAlg(x, y, w, h, 0, kFillMode_Gradient);
case kFillGradient:
VectorRendererSpec::drawSquareAlg(x, y, w, h, 0, kFillGradient);
if (Base::_strokeWidth)
drawSquareAlg(x, y, w, h, _fgColor, kFillMode_Disabled);
drawSquareAlg(x, y, w, h, _fgColor, kFillDisabled);
break;
}
}
@ -303,36 +303,36 @@ drawRoundedSquare(int x, int y, int r, int w, int h) {
if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h)
return;
if (Base::_fillMode != kFillMode_Disabled && Base::_shadowOffset
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
&& x + w + Base::_shadowOffset < Base::_activeSurface->w
&& y + h + Base::_shadowOffset < Base::_activeSurface->h) {
drawRoundedSquareShadow(x, y, r, w, h, Base::_shadowOffset);
}
switch(Base::_fillMode) {
case kFillMode_Disabled:
case kFillDisabled:
if (Base::_strokeWidth)
drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillMode_Disabled);
drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillDisabled);
break;
case kFillMode_Foreground:
drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillMode_Foreground);
case kFillForeground:
drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillForeground);
break;
case kFillMode_Background:
VectorRendererSpec::drawRoundedSquareAlg(x, y, r, w, h, _bgColor, kFillMode_Background);
drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillMode_Disabled);
case kFillBackground:
VectorRendererSpec::drawRoundedSquareAlg(x, y, r, w, h, _bgColor, kFillBackground);
drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillDisabled);
break;
case kFillMode_Gradient:
case kFillGradient:
if (Base::_strokeWidth > 1) {
drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillMode_Foreground);
drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillForeground);
VectorRendererSpec::drawRoundedSquareAlg(x + Base::_strokeWidth/2, y + Base::_strokeWidth/2,
r - Base::_strokeWidth/2, w - Base::_strokeWidth, h - Base::_strokeWidth, 0, kFillMode_Gradient);
r - Base::_strokeWidth/2, w - Base::_strokeWidth, h - Base::_strokeWidth, 0, kFillGradient);
} else {
VectorRendererSpec::drawRoundedSquareAlg(x, y, r, w, h, 0, kFillMode_Gradient);
VectorRendererSpec::drawRoundedSquareAlg(x, y, r, w, h, 0, kFillGradient);
if (Base::_strokeWidth)
drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillMode_Disabled);
drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillDisabled);
}
break;
}
@ -344,14 +344,14 @@ drawRoundedSquare(int x, int y, int r, int w, int h) {
/** SQUARE ALGORITHM **/
template<typename PixelType, typename PixelFormat>
void VectorRendererSpec<PixelType, PixelFormat>::
drawSquareAlg(int x, int y, int w, int h, PixelType color, FillMode fill_m) {
drawSquareAlg(int x, int y, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) {
PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x, y);
int pitch = Base::surfacePitch();
int max_h = h;
if (fill_m != kFillMode_Disabled) {
if (fill_m != kFillDisabled) {
while (h--) {
if (fill_m == kFillMode_Gradient)
if (fill_m == kFillGradient)
color = calcGradient(max_h - h, max_h);
colorFill(ptr, ptr + w, color);
@ -425,7 +425,7 @@ drawLineAlg(int x1, int y1, int x2, int y2, int dx, int dy, PixelType color) {
/** ROUNDED SQUARE ALGORITHM **/
template<typename PixelType, typename PixelFormat>
void VectorRendererSpec<PixelType, PixelFormat>::
drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, FillMode fill_m) {
drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) {
int f, ddF_x, ddF_y;
int x, y, px, py;
int pitch = Base::surfacePitch();
@ -441,7 +441,7 @@ drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, FillM
int short_h = h - (2 * r) + 2;
int long_h = h;
if (fill_m == kFillMode_Disabled) {
if (fill_m == kFillDisabled) {
while (sw++ < Base::_strokeWidth) {
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);
@ -470,7 +470,7 @@ drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, FillM
} else {
__BE_RESET();
if (fill_m == kFillMode_Gradient) {
if (fill_m == kFillGradient) {
while (x++ < y) {
__BE_ALGORITHM();
colorFill(ptr_tl - x - py, ptr_tr + x - py, calcGradient(real_radius - y, long_h));
@ -496,7 +496,7 @@ drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, FillM
ptr_fill += pitch * r;
while (short_h--) {
if (fill_m == kFillMode_Gradient)
if (fill_m == kFillGradient)
color = calcGradient(real_radius++, long_h);
colorFill(ptr_fill, ptr_fill + w + 1, color);
ptr_fill += pitch;
@ -507,13 +507,13 @@ drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, FillM
/** CIRCLE ALGORITHM **/
template<typename PixelType, typename PixelFormat>
void VectorRendererSpec<PixelType, PixelFormat>::
drawCircleAlg(int x1, int y1, int r, PixelType color, FillMode fill_m) {
drawCircleAlg(int x1, int y1, int r, PixelType color, VectorRenderer::FillMode fill_m) {
int f, ddF_x, ddF_y;
int x, y, px, py, sw = 0;
int pitch = Base::surfacePitch();
PixelType *ptr = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1);
if (fill_m == kFillMode_Disabled) {
if (fill_m == kFillDisabled) {
while (sw++ < Base::_strokeWidth) {
__BE_RESET();
r--;
@ -700,7 +700,7 @@ drawLineAlg(int x1, int y1, int x2, int y2, int dx, int dy, PixelType color) {
/** ROUNDED SQUARES **/
template<typename PixelType, typename PixelFormat>
void VectorRendererAA<PixelType, PixelFormat>::
drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, FillMode fill_m) {
drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) {
int x, y;
int p = Base::surfacePitch(), px, py;
int sw = 0, sp = 0, hp = h * p;
@ -717,7 +717,7 @@ drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, FillM
int short_h = h - 2 * r;
if (fill_m == kFillMode_Disabled) {
if (fill_m == VectorRenderer::kFillDisabled) {
while (sw++ < Base::_strokeWidth) {
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);
@ -770,7 +770,7 @@ drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, FillM
/** CIRCLES **/
template<typename PixelType, typename PixelFormat>
void VectorRendererAA<PixelType, PixelFormat>::
drawCircleAlg(int x1, int y1, int r, PixelType color, FillMode fill_m) {
drawCircleAlg(int x1, int y1, int r, PixelType color, VectorRenderer::FillMode fill_m) {
int x, y, sw = 0;
int p = Base::surfacePitch(), px, py;
@ -780,7 +780,7 @@ drawCircleAlg(int x1, int y1, int r, PixelType color, FillMode fill_m) {
PixelType *ptr = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1);
if (fill_m == kFillMode_Disabled) {
if (fill_m == VectorRenderer::kFillDisabled) {
while (sw++ < Base::_strokeWidth) {
x = r - (sw - 1); y = 0; T = 0;
px = p * x; py = 0;

View file

@ -27,23 +27,17 @@
#define VECTOR_RENDERER_H
#include "common/scummsys.h"
#include "common/system.h"
#include "graphics/surface.h"
#include "graphics/colormasks.h"
#include "common/system.h"
#include "gui/InterfaceManager.h"
namespace Graphics {
class VectorRenderer;
VectorRenderer *createRenderer(int mode);
/** Specifies the way in which a shape is filled */
enum FillMode {
kFillMode_Disabled = 0,
kFillMode_Foreground = 1,
kFillMode_Background = 2,
kFillMode_Gradient = 3
};
struct DrawStep {
uint32 flags; /** Step flags, see DrawStepFlags */
@ -56,22 +50,24 @@ struct DrawStep {
uint16 x, y, w, h, r; /** Shape size */
uint8 shadow, stroke, factor; /** Misc options... */
FillMode fill_mode; /** active fill mode */
int fill_mode; /** active fill mode */
void (VectorRenderer::*drawing_call)(DrawStep*); /** Pointer to drawing function */
enum DrawStepFlags {
kStepCallbackOnly = (1 << 0),
kStepSettingsOnly = (1 << 1),
kStepSetBG = (1 << 2),
kStepSetFG = (1 << 3),
kStepSetGradient = (1 << 4),
kStepSetShadow = (1 << 5),
kStepSetGradientFactor = (1 << 6),
kStepSetStroke = (1 << 7),
kStepSetFillMode = (1 << 8)
};
};
enum DrawStepFlags {
kDrawStep_CallbackOnly = (1 << 0),
kDrawStep_SettingsOnly = (1 << 1),
kDrawStep_SetBG = (1 << 2),
kDrawStep_SetFG = (1 << 3),
kDrawStep_SetGradient = (1 << 4),
kDrawStep_SetShadow = (1 << 5),
kDrawStep_SetGradientFactor = (1 << 6),
kDrawStep_SetStroke = (1 << 7),
kDrawStep_SetFillMode = (1 << 8)
};
VectorRenderer *createRenderer(int mode);
/**
* VectorRenderer: The core Vector Renderer Class
@ -90,9 +86,17 @@ enum DrawStepFlags {
*/
class VectorRenderer {
public:
VectorRenderer() : _shadowOffset(0), _fillMode(kFillMode_Disabled), _activeSurface(NULL), _strokeWidth(1), _gradientFactor(1) {}
VectorRenderer() : _shadowOffset(0), _fillMode(kFillDisabled), _activeSurface(NULL), _strokeWidth(1), _gradientFactor(1) {}
virtual ~VectorRenderer() {}
/** Specifies the way in which a shape is filled */
enum FillMode {
kFillDisabled = 0,
kFillForeground = 1,
kFillBackground = 2,
kFillGradient = 3
};
/**
* Draws a line by considering the special cases for optimization.
*
@ -183,7 +187,7 @@ public:
virtual void setBgColor(uint8 r, uint8 g, uint8 b) = 0;
/**
* Set the active gradient color. All shapes drawn using kFillMode_Gradient
* Set the active gradient color. All shapes drawn using kFillGradient
* 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
@ -311,7 +315,6 @@ protected:
int _gradientBytes[3]; /** Color bytes of the active gradient, used to speed up calculation */
};
/**
* VectorRendererSpec: Specialized Vector Renderer Class
*
@ -392,11 +395,11 @@ public:
int h = _activeSurface->h ;
int pitch = surfacePitch();
if (Base::_fillMode == kFillMode_Background)
if (Base::_fillMode == kFillBackground)
colorFill(ptr, ptr + w * h, _bgColor);
else if (Base::_fillMode == kFillMode_Foreground)
else if (Base::_fillMode == kFillForeground)
colorFill(ptr, ptr + w * h, _fgColor);
else if (Base::_fillMode == kFillMode_Gradient) {
else if (Base::_fillMode == kFillGradient) {
int i = h;
while (i--) {
colorFill(ptr, ptr + w, calcGradient(h - i, h));
@ -622,7 +625,7 @@ protected:
*
* @see VectorRenderer::drawCircleAlg()
*/
virtual void drawCircleAlg(int x, int y, int r, PixelType color, FillMode fill_m);
virtual void drawCircleAlg(int x, int y, int r, PixelType color, VectorRenderer::FillMode fill_m);
/**
* "Wu's Circle Antialiasing Algorithm" as published by Xiaolin Wu, July 1991,
@ -631,7 +634,7 @@ protected:
*
* @see VectorRenderer::drawRoundedAlg()
*/
virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, FillMode fill_m);
virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m);
};
} // end of namespace Graphics

View file

@ -34,11 +34,13 @@
namespace GUI {
using namespace Graphics;
template<typename PixelType>
void InterfaceManager::screenInit() {
freeScreen();
_screen = new Graphics::Surface;
_screen = new Surface;
_screen->create(_system->getOverlayWidth(), _system->getOverlayHeight(), sizeof(PixelType));
_system->clearOverlay();
}
@ -50,12 +52,12 @@ void InterfaceManager::setGraphicsMode(Graphics_Mode mode) {
_graphicsMode = mode;
switch (mode) {
case GFX_Standard_16bit:
case kGfxStandard16bit:
_bytesPerPixel = sizeof(uint16);
screenInit<uint16>();
break;
case GFX_Antialias_16bit:
case kGfxAntialias16bit:
_bytesPerPixel = sizeof(uint16);
screenInit<uint16>();
break;
@ -64,7 +66,7 @@ void InterfaceManager::setGraphicsMode(Graphics_Mode mode) {
return;
}
_vectorRenderer = Graphics::createRenderer(mode);
_vectorRenderer = createRenderer(mode);
_vectorRenderer->setSurface(_screen);
}
@ -80,9 +82,9 @@ int InterfaceManager::runGUI() {
steps[0].color2.r = 240;
steps[0].color2.g = 200;
steps[0].color2.b = 25;
steps[0].fill_mode = Graphics::kFillMode_Gradient;
steps[0].drawing_call = &Graphics::VectorRenderer::drawCallback_FILLSURFACE;
steps[0].flags = Graphics::kDrawStep_SetGradient | Graphics::kDrawStep_SetFillMode;
steps[0].fill_mode = VectorRenderer::kFillGradient;
steps[0].drawing_call = &VectorRenderer::drawCallback_FILLSURFACE;
steps[0].flags = DrawStep::kStepSetGradient | DrawStep::kStepSetFillMode;
steps[1].color1.r = 206;
steps[1].color1.g = 121;
@ -95,24 +97,24 @@ int InterfaceManager::runGUI() {
steps[1].r = 8;
steps[1].w = 120;
steps[1].h = 30;
steps[1].drawing_call = &Graphics::VectorRenderer::drawCallback_ROUNDSQ;
steps[1].flags = Graphics::kDrawStep_SetGradient;
steps[1].drawing_call = &VectorRenderer::drawCallback_ROUNDSQ;
steps[1].flags = DrawStep::kStepSetGradient;
steps[2].x = 500;
steps[2].y = 135;
steps[2].r = 8;
steps[2].w = 120;
steps[2].h = 30;
steps[2].drawing_call = &Graphics::VectorRenderer::drawCallback_ROUNDSQ;
steps[2].flags = Graphics::kDrawStep_CallbackOnly;
steps[2].drawing_call = &VectorRenderer::drawCallback_ROUNDSQ;
steps[2].flags = DrawStep::kStepCallbackOnly;
steps[3].x = 500;
steps[3].y = 175;
steps[3].r = 8;
steps[3].w = 120;
steps[3].h = 30;
steps[3].drawing_call = &Graphics::VectorRenderer::drawCallback_ROUNDSQ;
steps[3].flags = Graphics::kDrawStep_CallbackOnly;
steps[3].drawing_call = &VectorRenderer::drawCallback_ROUNDSQ;
steps[3].flags = DrawStep::kStepCallbackOnly;
bool running = true;
while (running) { // draw!!

View file

@ -38,13 +38,13 @@ class InterfaceManager {
public:
enum Graphics_Mode {
GFX_Disabled = 0,
GFX_Standard_16bit,
GFX_Antialias_16bit
kGfxDisabled = 0,
kGfxStandard16bit,
kGfxAntialias16bit
};
InterfaceManager(OSystem *system, Graphics_Mode mode) : _vectorRenderer(0),
_system(system), _graphicsMode(GFX_Disabled), _screen(0), _bytesPerPixel(0) {
_system(system), _graphicsMode(kGfxDisabled), _screen(0), _bytesPerPixel(0) {
setGraphicsMode(mode);
}