diff options
-rw-r--r-- | graphics/VectorRenderer.cpp | 96 | ||||
-rw-r--r-- | graphics/VectorRenderer.h | 38 | ||||
-rw-r--r-- | gui/InterfaceManager.cpp | 2 | ||||
-rw-r--r-- | gui/InterfaceManager.h | 5 |
4 files changed, 71 insertions, 70 deletions
diff --git a/graphics/VectorRenderer.cpp b/graphics/VectorRenderer.cpp index e2b187a58c..9bd2ca7e01 100644 --- a/graphics/VectorRenderer.cpp +++ b/graphics/VectorRenderer.cpp @@ -65,13 +65,13 @@ void vector_renderer_test(OSystem *_system) { vr->setFgColor(255, 0, 206); vr->setGradientFactor(1); vr->setGradientColors(214, 113, 8, 240, 200, 25); - vr->fillSurface(VectorRenderer::kGradientFill); + vr->fillSurface(kFillMode_Gradient); vr->setBgColor(25, 25, 175); vr->shadowEnable(3); vr->setFgColor(240, 204, 120); vr->setStrokeWidth(1); - vr->setFillMode(VectorRenderer::kGradientFill); + vr->setFillMode(kFillMode_Gradient); vr->setGradientFactor(3); 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) return; - if (Base::_fillMode != kNoFill && Base::_shadowOffset + if (Base::_fillMode != kFillMode_Disabled && 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, kForegroundFill); + drawCircleAlg(x + Base::_shadowOffset + 1, y + Base::_shadowOffset + 1, r, 0, kFillMode_Foreground); } switch(Base::_fillMode) { - case kNoFill: + case kFillMode_Disabled: if (Base::_strokeWidth) - drawCircleAlg(x, y, r, _fgColor, kNoFill); + drawCircleAlg(x, y, r, _fgColor, kFillMode_Disabled); break; - case kForegroundFill: - drawCircleAlg(x, y, r, _fgColor, kForegroundFill); + case kFillMode_Foreground: + drawCircleAlg(x, y, r, _fgColor, kFillMode_Foreground); break; - case kBackgroundFill: + case kFillMode_Background: if (Base::_strokeWidth > 1) { - drawCircleAlg(x, y, r, _fgColor, kForegroundFill); - drawCircleAlg(x, y, r - Base::_strokeWidth, _bgColor, kBackgroundFill); + drawCircleAlg(x, y, r, _fgColor, kFillMode_Foreground); + drawCircleAlg(x, y, r - Base::_strokeWidth, _bgColor, kFillMode_Background); } else { - drawCircleAlg(x, y, r, _bgColor, kBackgroundFill); - drawCircleAlg(x, y, r, _fgColor, kNoFill); + drawCircleAlg(x, y, r, _bgColor, kFillMode_Background); + drawCircleAlg(x, y, r, _fgColor, kFillMode_Disabled); } break; - case kGradientFill: + case kFillMode_Gradient: 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) return; - if (Base::_fillMode != kNoFill && Base::_shadowOffset + if (Base::_fillMode != kFillMode_Disabled && 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 kNoFill: + case kFillMode_Disabled: if (Base::_strokeWidth) - drawSquareAlg(x, y, w, h, _fgColor, kNoFill); + drawSquareAlg(x, y, w, h, _fgColor, kFillMode_Disabled); break; - case kForegroundFill: - drawSquareAlg(x, y, w, h, _fgColor, kForegroundFill); + case kFillMode_Foreground: + drawSquareAlg(x, y, w, h, _fgColor, kFillMode_Foreground); break; - case kBackgroundFill: - drawSquareAlg(x, y, w, h, _bgColor, kBackgroundFill); - drawSquareAlg(x, y, w, h, _fgColor, kNoFill); + case kFillMode_Background: + drawSquareAlg(x, y, w, h, _bgColor, kFillMode_Background); + drawSquareAlg(x, y, w, h, _fgColor, kFillMode_Disabled); break; - case kGradientFill: - VectorRendererSpec::drawSquareAlg(x, y, w, h, 0, kGradientFill); + case kFillMode_Gradient: + VectorRendererSpec::drawSquareAlg(x, y, w, h, 0, kFillMode_Gradient); if (Base::_strokeWidth) - drawSquareAlg(x, y, w, h, _fgColor, kNoFill); + drawSquareAlg(x, y, w, h, _fgColor, kFillMode_Disabled); 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) return; - if (Base::_fillMode != kNoFill && Base::_shadowOffset + if (Base::_fillMode != kFillMode_Disabled && 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 kNoFill: + case kFillMode_Disabled: if (Base::_strokeWidth) - drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kNoFill); + drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillMode_Disabled); break; - case kForegroundFill: - drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kForegroundFill); + case kFillMode_Foreground: + drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillMode_Foreground); break; - case kBackgroundFill: - VectorRendererSpec::drawRoundedSquareAlg(x, y, r, w, h, _bgColor, kBackgroundFill); - drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kNoFill); + case kFillMode_Background: + VectorRendererSpec::drawRoundedSquareAlg(x, y, r, w, h, _bgColor, kFillMode_Background); + drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillMode_Disabled); break; - case kGradientFill: + case kFillMode_Gradient: 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, - 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 { - VectorRendererSpec::drawRoundedSquareAlg(x, y, r, w, h, 0, kGradientFill); + VectorRendererSpec::drawRoundedSquareAlg(x, y, r, w, h, 0, kFillMode_Gradient); if (Base::_strokeWidth) - drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kNoFill); + drawRoundedSquareAlg(x, y, r, w, h, _fgColor, kFillMode_Disabled); } break; } @@ -360,9 +360,9 @@ drawSquareAlg(int x, int y, int w, int h, PixelType color, FillMode fill_m) { int pitch = Base::surfacePitch(); int max_h = h; - if (fill_m != kNoFill) { + if (fill_m != kFillMode_Disabled) { while (h--) { - if (fill_m == kGradientFill) + if (fill_m == kFillMode_Gradient) color = calcGradient(max_h - h, max_h); 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 long_h = h; - if (fill_m == kNoFill) { + if (fill_m == kFillMode_Disabled) { 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); @@ -481,7 +481,7 @@ drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, FillM } else { __BE_RESET(); - if (fill_m == kGradientFill) { + if (fill_m == kFillMode_Gradient) { while (x++ < y) { __BE_ALGORITHM(); 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; while (short_h--) { - if (fill_m == kGradientFill) + if (fill_m == kFillMode_Gradient) color = calcGradient(real_radius++, long_h); colorFill(ptr_fill, ptr_fill + w + 1, color); ptr_fill += pitch; @@ -524,7 +524,7 @@ drawCircleAlg(int x1, int y1, int r, PixelType color, FillMode fill_m) { int pitch = Base::surfacePitch(); PixelType *ptr = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1); - if (fill_m == kNoFill) { + if (fill_m == kFillMode_Disabled) { while (sw++ < Base::_strokeWidth) { __BE_RESET(); r--; @@ -711,7 +711,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, VectorRenderer::FillMode fill_m) { +drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, FillMode fill_m) { int x, y; int p = Base::surfacePitch(), px, py; 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; - if (fill_m == VectorRenderer::kNoFill) { + if (fill_m == kFillMode_Disabled) { 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); @@ -781,7 +781,7 @@ drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, Vecto /** CIRCLES **/ template<typename PixelType, typename 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 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); - if (fill_m == VectorRenderer::kNoFill) { + if (fill_m == kFillMode_Disabled) { 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 23e5b18593..3cd3a27ca4 100644 --- a/graphics/VectorRenderer.h +++ b/graphics/VectorRenderer.h @@ -35,6 +35,14 @@ namespace Graphics { 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 { bool set_fg, set_bg, set_grad; @@ -47,7 +55,7 @@ struct DrawStep { uint16 x, y, w, h, r; uint8 shadows, stroke, factor; - Graphics::VectorRenderer::FillMode fill_mode; + FillMode fill_mode; void (*drawing_call)(DrawStep *step); }; @@ -70,17 +78,9 @@ struct DrawStep { */ class VectorRenderer { 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() {} - /** 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. * @@ -171,7 +171,7 @@ public: 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. * * @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 */ - virtual void fillSurface(FillMode mode = kForegroundFill) = 0; + virtual void fillSurface(FillMode mode = kFillMode_Foreground) = 0; /** * Clears the active surface. @@ -215,7 +215,7 @@ public: * @see VectorRenderer::FillMode * @param mode Specified fill mode. */ - virtual void setFillMode(VectorRenderer::FillMode mode) { + virtual void setFillMode(FillMode mode) { _fillMode = mode; } @@ -370,18 +370,18 @@ public: /** * @see VectorRenderer::fillSurface() */ - void fillSurface(FillMode mode = kForegroundFill) { + void fillSurface(FillMode mode = kFillMode_Foreground) { PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(0, 0); int w = _activeSurface->w; int h = _activeSurface->h ; int pitch = surfacePitch(); - if (mode == kBackgroundFill) + if (mode == kFillMode_Background) colorFill(ptr, ptr + w * h, _bgColor); - else if (mode == kForegroundFill) + else if (mode == kFillMode_Foreground) colorFill(ptr, ptr + w * h, _fgColor); - else if (mode == kGradientFill) { + else if (mode == kFillMode_Gradient) { int i = h; while (i--) { colorFill(ptr, ptr + w, calcGradient(h - i, h)); @@ -596,7 +596,7 @@ protected: * * @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, @@ -605,7 +605,7 @@ protected: * * @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 diff --git a/gui/InterfaceManager.cpp b/gui/InterfaceManager.cpp index 693b36e367..f886423e4c 100644 --- a/gui/InterfaceManager.cpp +++ b/gui/InterfaceManager.cpp @@ -36,4 +36,4 @@ namespace GUI { -} // end of namespace GUI.
\ No newline at end of file +} // end of namespace GUI. diff --git a/gui/InterfaceManager.h b/gui/InterfaceManager.h index b65ae36477..92f5c570a4 100644 --- a/gui/InterfaceManager.h +++ b/gui/InterfaceManager.h @@ -29,6 +29,7 @@ #include "common/scummsys.h" #include "graphics/surface.h" #include "common/system.h" + #include "graphics/VectorRenderer.h" namespace GUI { @@ -48,7 +49,7 @@ protected: Graphics::VectorRenderer *createRenderer() { // TODO: Find out what pixel format we are using, // create the renderer accordingly - return new VectorRendererSpec<uint16, ColorMasks<565> >; + return new Graphics::VectorRendererSpec<uint16, ColorMasks<565> >; } Graphics::VectorRenderer *_vectorRenderer; @@ -56,4 +57,4 @@ protected: } // end of namespace GUI. -#endif
\ No newline at end of file +#endif |