diff options
author | Vicent Marti | 2008-05-28 15:03:30 +0000 |
---|---|---|
committer | Vicent Marti | 2008-05-28 15:03:30 +0000 |
commit | 8a83eafbf3119c4acec8e294b883da4c500efeeb (patch) | |
tree | 5f16fd573b89852daeefbc233335492134b4332d /graphics | |
parent | 74c458153e5674758e8bd425c9205beb6412726b (diff) | |
download | scummvm-rg350-8a83eafbf3119c4acec8e294b883da4c500efeeb.tar.gz scummvm-rg350-8a83eafbf3119c4acec8e294b883da4c500efeeb.tar.bz2 scummvm-rg350-8a83eafbf3119c4acec8e294b883da4c500efeeb.zip |
Misc fixes.
Constant naming fixes.
svn-id: r32342
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/VectorRenderer.cpp | 124 | ||||
-rw-r--r-- | graphics/VectorRenderer.h | 65 |
2 files changed, 96 insertions, 93 deletions
diff --git a/graphics/VectorRenderer.cpp b/graphics/VectorRenderer.cpp index dfb555c20b..aba940e386 100644 --- a/graphics/VectorRenderer.cpp +++ b/graphics/VectorRenderer.cpp @@ -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; diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h index 65d0cce417..98bb25a2cb 100644 --- a/graphics/VectorRenderer.h +++ b/graphics/VectorRenderer.h @@ -27,22 +27,16 @@ #define VECTOR_RENDERER_H #include "common/scummsys.h" +#include "common/system.h" + #include "graphics/surface.h" #include "graphics/colormasks.h" -#include "common/system.h" -namespace Graphics { -class VectorRenderer; +#include "gui/InterfaceManager.h" -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 -}; +namespace Graphics { +class VectorRenderer; struct DrawStep { uint32 flags; /** Step flags, see DrawStepFlags */ @@ -56,23 +50,25 @@ 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 { - 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) + 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) + }; }; +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 |