diff options
author | Vicent Marti | 2008-08-02 22:11:57 +0000 |
---|---|---|
committer | Vicent Marti | 2008-08-02 22:11:57 +0000 |
commit | a3f85956ff851321495404030146c5f60bf1018d (patch) | |
tree | b853d0be8fe37eb365d3fb72b0654bc052b7cfa1 /graphics | |
parent | 03ffc30bdce0a62ce3cd3bcbd439d0f70e4dadf5 (diff) | |
download | scummvm-rg350-a3f85956ff851321495404030146c5f60bf1018d.tar.gz scummvm-rg350-a3f85956ff851321495404030146c5f60bf1018d.tar.bz2 scummvm-rg350-a3f85956ff851321495404030146c5f60bf1018d.zip |
Added basic support for inner shadows.
Made sliders look pretty much like the current GUI.
svn-id: r33548
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/VectorRenderer.cpp | 62 | ||||
-rw-r--r-- | graphics/VectorRenderer.h | 11 |
2 files changed, 71 insertions, 2 deletions
diff --git a/graphics/VectorRenderer.cpp b/graphics/VectorRenderer.cpp index 3bd3b86cf8..db9b774857 100644 --- a/graphics/VectorRenderer.cpp +++ b/graphics/VectorRenderer.cpp @@ -75,6 +75,7 @@ void VectorRenderer::drawStep(const Common::Rect &area, const DrawStep &step, ui step.gradColor2.r, step.gradColor2.g, step.gradColor2.b); setShadowOffset(_disableShadows ? 0 : step.shadow); + setInnerShadowOffset(_disableShadows ? 0 : step.innerShadow); setGradientFactor(step.factor); setStrokeWidth(step.stroke); setFillMode((FillMode)step.fillMode); @@ -511,6 +512,9 @@ drawRoundedSquare(int x, int y, int r, int w, int h) { } break; } + + if (Base::_innerShadowOffset) + drawRoundedSquareInnerShadow(x, y, r, w, h, Base::_innerShadowOffset); } template<typename PixelType, typename PixelFormat> @@ -1154,6 +1158,62 @@ drawRoundedSquareShadow(int x1, int y1, int r, int w, int h, int blur) { } } +template<typename PixelType, typename PixelFormat> +void VectorRendererSpec<PixelType, PixelFormat>:: +drawRoundedSquareInnerShadow(int x1, int y1, int r, int w, int h, int blur) { + int x, y; + int p = Base::surfacePitch(), px, py; + int sw = 0, sp = 0; + + uint32 rsq = (r * r) << 16; + uint32 T = 0, oldT; + uint8 a1, a2; + + PixelType color = RGBToColor<PixelFormat>(63, 60, 17); + + PixelType *ptr_tl = (PixelType *)Base::_activeSurface->getBasePtr(x1 + r, y1 + r); + PixelType *ptr_tr = (PixelType *)Base::_activeSurface->getBasePtr(x1 + w - r, y1 + r); + PixelType *ptr_bl = (PixelType *)Base::_activeSurface->getBasePtr(x1 + r, y1 + h - r); + PixelType *ptr_fill = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1); + + int short_h = h - 2 * r; + + while (sw++ < blur) { + colorFill(ptr_fill + sp + r, ptr_fill + w + 1 + sp - r, color); + sp += p; + + x = r - (sw - 1); y = 0; T = 0; + px = p * x; py = 0; + + while (x > y++) { + __WU_ALGORITHM(); + + a1 = a1 * 3 / 4; + a2 = a2 * 3 / 4; + + blendPixelPtr(ptr_tr + (y) - (px - p), color, a2); + blendPixelPtr(ptr_tr + (x - 1) - (py), color, a2); + blendPixelPtr(ptr_tl - (x - 1) - (py), color, a2); + blendPixelPtr(ptr_tl - (y) - (px - p), color, a2); + blendPixelPtr(ptr_bl - (y) + (px - p), color, a2); + blendPixelPtr(ptr_bl - (x - 1) + (py), color, a2); + + blendPixelPtr(ptr_tr + (y) - (px), color, a1); + blendPixelPtr(ptr_tr + (x) - (py), color, a1); + blendPixelPtr(ptr_tl - (x) - (py), color, a1); + blendPixelPtr(ptr_tl - (y) - (px), color, a1); + blendPixelPtr(ptr_bl - (y) + (px), color, a1); + blendPixelPtr(ptr_bl - (x) + (py), color, a1); + } + } + + ptr_fill += p * r; + while (short_h-- >= 0) { + colorFill(ptr_fill, ptr_fill + blur, color); + ptr_fill += p; + } +} + /******************************************************************** * ANTIALIASED PRIMITIVES drawing algorithms - VectorRendererAA @@ -1255,7 +1315,7 @@ drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, Vecto colorFill(ptr_fill, ptr_fill + Base::_strokeWidth, color); colorFill(ptr_fill + w - Base::_strokeWidth + 1, ptr_fill + w + 1, color); ptr_fill += p; - } + } } else { x = r; y = 0; T = 0; px = p * x; py = 0; diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h index b85ad8a9c9..3756730720 100644 --- a/graphics/VectorRenderer.h +++ b/graphics/VectorRenderer.h @@ -62,7 +62,7 @@ struct DrawStep { kVectorAlignCenter } xAlign, yAlign; - uint8 shadow, stroke, factor, radius; /** Misc options... */ + uint8 shadow, stroke, factor, radius, innerShadow; /** Misc options... */ uint8 fillMode; /** active fill mode */ uint32 extraData; /** Generic parameter for extra options (orientation/bevel) */ @@ -329,6 +329,11 @@ public: if (offset >= 0) _shadowOffset = offset; } + + virtual void setInnerShadowOffset(int offset) { + if (offset >= 0) + _innerShadowOffset = offset; + } /** * Sets the multiplication factor of the active gradient. @@ -445,6 +450,7 @@ protected: FillMode _fillMode; /** Defines in which way (if any) are filled the drawn shapes */ int _shadowOffset; /** offset for drawn shadows */ + int _innerShadowOffset; bool _disableShadows; /** Disables temporarily shadow drawing for overlayed images. */ int _strokeWidth; /** Width of the stroke of all drawn shapes */ uint32 _dynamicData; /** Dynamic data from the GUI Theme that modifies the drawing of the current shape */ @@ -677,6 +683,8 @@ protected: * @param alpha Alpha intensity of the pixel (0-255) */ virtual inline void blendPixelPtr(PixelType *ptr, PixelType color, uint8 alpha) { + if (!ptr) return; + if (alpha == 255) { *ptr = color; return; @@ -729,6 +737,7 @@ protected: */ virtual void drawSquareShadow(int x, int y, int w, int h, int blur); virtual void drawRoundedSquareShadow(int x, int y, int r, int w, int h, int blur); + virtual void drawRoundedSquareInnerShadow(int x, int y, int r, int w, int h, int bur); /** * Calculates the color gradient on a given point. |