ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

VectorRendererSpec.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef VECTOR_RENDERER_SPEC_H
00024 #define VECTOR_RENDERER_SPEC_H
00025 
00026 #include "graphics/VectorRenderer.h"
00027 
00028 namespace Graphics {
00029 
00046 template<typename PixelType>
00047 class VectorRendererSpec : public VectorRenderer {
00048     typedef VectorRenderer Base;
00049 
00050 public:
00051     VectorRendererSpec(PixelFormat format);
00052 
00053     void drawLine(int x1, int y1, int x2, int y2);
00054     void drawLineClip(int x1, int y1, int x2, int y2, Common::Rect clipping);
00055     void drawCircle(int x, int y, int r);
00056     void drawCircleClip(int x, int y, int r, Common::Rect clipping);
00057     void drawSquare(int x, int y, int w, int h);
00058     void drawSquareClip(int x, int y, int w, int h, Common::Rect clipping);
00059     void drawRoundedSquare(int x, int y, int r, int w, int h);
00060     void drawRoundedSquareClip(int x, int y, int r, int w, int h, Common::Rect clipping);
00061     void drawTriangle(int x, int y, int base, int height, TriangleOrientation orient);
00062     void drawTriangleClip(int x, int y, int base, int height, TriangleOrientation orient, Common::Rect clipping);
00063     void drawTab(int x, int y, int r, int w, int h);
00064     void drawTabClip(int x, int y, int r, int w, int h, Common::Rect clipping);
00065     void drawBeveledSquare(int x, int y, int w, int h, int bevel) {
00066         drawBevelSquareAlg(x, y, w, h, bevel, _bevelColor, _fgColor, Base::_fillMode != kFillDisabled);
00067     }
00068     void drawBeveledSquareClip(int x, int y, int w, int h, int bevel, Common::Rect clipping) {
00069         bool useClippingVersions = !(clipping.isEmpty() || clipping.contains(Common::Rect(x, y, x + w, y + h)));
00070         if (useClippingVersions) {
00071             Common::Rect backup = _clippingArea;
00072             _clippingArea = clipping;
00073             drawBevelSquareAlgClip(x, y, w, h, bevel, _bevelColor, _fgColor, Base::_fillMode != kFillDisabled);
00074             _clippingArea = backup;
00075         } else {
00076             drawBevelSquareAlg(x, y, w, h, bevel, _bevelColor, _fgColor, Base::_fillMode != kFillDisabled);
00077         }
00078     }
00079     void drawString(const Graphics::Font *font, const Common::String &text,
00080                     const Common::Rect &area, Graphics::TextAlign alignH,
00081                     GUI::ThemeEngine::TextAlignVertical alignV, int deltax, bool elipsis, const Common::Rect &textDrawableArea = Common::Rect(0, 0, 0, 0));
00082 
00083     void setFgColor(uint8 r, uint8 g, uint8 b) { _fgColor = _format.RGBToColor(r, g, b); }
00084     void setBgColor(uint8 r, uint8 g, uint8 b) { _bgColor = _format.RGBToColor(r, g, b); }
00085     void setBevelColor(uint8 r, uint8 g, uint8 b) { _bevelColor = _format.RGBToColor(r, g, b); }
00086     void setGradientColors(uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2);
00087 
00088     void copyFrame(OSystem *sys, const Common::Rect &r);
00089     void copyWholeFrame(OSystem *sys) { copyFrame(sys, Common::Rect(0, 0, _activeSurface->w, _activeSurface->h)); }
00090 
00091     void fillSurface();
00092     void fillSurfaceClip(Common::Rect clipping);
00093     void blitSurface(const Graphics::Surface *source, const Common::Rect &r);
00094     void blitSubSurface(const Graphics::Surface *source, const Common::Rect &r);
00095     void blitSubSurfaceClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping);
00096     void blitKeyBitmap(const Graphics::Surface *source, const Common::Rect &r);
00097     void blitKeyBitmapClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping);
00098     void blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r,
00099             GUI::ThemeEngine::AutoScaleMode autoscale = GUI::ThemeEngine::kAutoScaleNone,
00100             Graphics::DrawStep::VectorAlignment xAlign = Graphics::DrawStep::kVectorAlignManual,
00101             Graphics::DrawStep::VectorAlignment yAlign = Graphics::DrawStep::kVectorAlignManual,
00102             int alpha = 255);
00103 
00104     void applyScreenShading(GUI::ThemeEngine::ShadingStyle shadingStyle);
00105 
00106 protected:
00107 
00108     Common::Rect _clippingArea;
00109 
00118     inline void putPixel(int x, int y, PixelType color) {
00119         PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x, y);
00120         *ptr = color;
00121     }
00122 
00132     inline void blendPixel(int x, int y, PixelType color, uint8 alpha) {
00133         blendPixelPtr((PixelType *)Base::_activeSurface->getBasePtr(x, y), color, alpha);
00134     }
00135 
00148     inline void blendPixelPtr(PixelType *ptr, PixelType color, uint8 alpha);
00149     inline void blendPixelPtrClip(PixelType *ptr, PixelType color, uint8 alpha, int x, int y);
00150 
00166     inline void blendPixelDestAlphaPtr(PixelType *ptr, PixelType color, uint8 alpha);
00167 
00168 
00180     virtual void drawLineAlg(int x1, int y1, int x2, int y2,
00181         uint dx, uint dy, PixelType color);
00182 
00183     virtual void drawLineAlgClip(int x1, int y1, int x2, int y2,
00184         uint dx, uint dy, PixelType color);
00185 
00186     virtual void drawCircleAlg(int x, int y, int r,
00187         PixelType color, FillMode fill_m);
00188 
00189     virtual void drawCircleAlgClip(int x, int y, int r,
00190         PixelType color, FillMode fill_m);
00191 
00192     virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h,
00193         PixelType color, FillMode fill_m);
00194 
00195     virtual void drawRoundedSquareAlgClip(int x1, int y1, int r, int w, int h,
00196         PixelType color, FillMode fill_m);
00197 
00198     virtual void drawBorderRoundedSquareAlg(int x1, int y1, int r, int w, int h,
00199         PixelType color, FillMode fill_m, uint8 alpha_t, uint8 alpha_r, uint8 alpha_b, uint8 alpha_l);
00200 
00201     virtual void drawBorderRoundedSquareAlgClip(int x1, int y1, int r, int w, int h,
00202         PixelType color, FillMode fill_m, uint8 alpha_t, uint8 alpha_r, uint8 alpha_b, uint8 alpha_l);
00203 
00204     virtual void drawInteriorRoundedSquareAlg(int x1, int y1, int r, int w, int h,
00205         PixelType color, FillMode fill_m);
00206 
00207     virtual void drawInteriorRoundedSquareAlgClip(int x1, int y1, int r, int w, int h,
00208         PixelType color, FillMode fill_m);
00209 
00210     virtual void drawSquareAlg(int x, int y, int w, int h,
00211         PixelType color, FillMode fill_m);
00212 
00213     virtual void drawSquareAlgClip(int x, int y, int w, int h,
00214         PixelType color, FillMode fill_m);
00215 
00216     virtual void drawTriangleVertAlg(int x, int y, int w, int h,
00217         bool inverted, PixelType color, FillMode fill_m);
00218 
00219     virtual void drawTriangleVertAlgClip(int x, int y, int w, int h,
00220         bool inverted, PixelType color, FillMode fill_m);
00221 
00222     virtual void drawTriangleFast(int x, int y, int size,
00223         bool inverted, PixelType color, FillMode fill_m);
00224 
00225     virtual void drawBevelSquareAlg(int x, int y, int w, int h,
00226         int bevel, PixelType top_color, PixelType bottom_color, bool fill);
00227 
00228     virtual void drawBevelSquareAlgClip(int x, int y, int w, int h,
00229         int bevel, PixelType top_color, PixelType bottom_color, bool fill);
00230 
00231     virtual void drawTabAlg(int x, int y, int w, int h, int r,
00232         PixelType color, VectorRenderer::FillMode fill_m,
00233         int baseLeft = 0, int baseRight = 0);
00234 
00235     virtual void drawTabAlgClip(int x, int y, int w, int h, int r,
00236         PixelType color, VectorRenderer::FillMode fill_m,
00237         int baseLeft = 0, int baseRight = 0);
00238 
00239     virtual void drawTabShadow(int x, int y, int w, int h, int r);
00240 
00241     virtual void drawTabShadowClip(int x, int y, int w, int h, int r);
00242 
00243     virtual void drawBevelTabAlg(int x, int y, int w, int h,
00244         int bevel, PixelType topColor, PixelType bottomColor,
00245         int baseLeft = 0, int baseRight = 0);
00246 
00247     virtual void drawBevelTabAlgClip(int x, int y, int w, int h,
00248         int bevel, PixelType topColor, PixelType bottomColor,
00249         int baseLeft = 0, int baseRight = 0);
00250 
00261     virtual void drawSquareShadow(int x, int y, int w, int h, int offset);
00262     virtual void drawSquareShadowClip(int x, int y, int w, int h, int offset);
00263     virtual void drawRoundedSquareShadow(int x, int y, int r, int w, int h, int offset);
00264     virtual void drawRoundedSquareShadowClip(int x, int y, int r, int w, int h, int offset);
00265 
00275     inline PixelType calcGradient(uint32 pos, uint32 max);
00276 
00277     void precalcGradient(int h);
00278     void gradientFill(PixelType *first, int width, int x, int y);
00279     void gradientFillClip(PixelType *first, int width, int x, int y, int realX, int realY);
00280 
00291     inline void blendFill(PixelType *first, PixelType *last, PixelType color, uint8 alpha) {
00292         while (first != last)
00293             blendPixelPtr(first++, color, alpha);
00294     }
00295 
00296     inline void blendFillClip(PixelType *first, PixelType *last, PixelType color, uint8 alpha, int realX, int realY) {
00297         if (_clippingArea.top <= realY && realY < _clippingArea.bottom) {
00298             while (first != last) {
00299                 if (_clippingArea.left <= realX && realX < _clippingArea.right)
00300                     blendPixelPtr(first++, color, alpha);
00301                 else
00302                     ++first;
00303                 ++realX;
00304             }
00305         }
00306     }
00307 
00308     void darkenFill(PixelType *first, PixelType *last);
00309     void darkenFillClip(PixelType *first, PixelType *last, int x, int y);
00310 
00311     const PixelFormat _format;
00312     const PixelType _redMask, _greenMask, _blueMask, _alphaMask;
00313 
00314     PixelType _fgColor; 
00315     PixelType _bgColor; 
00317     PixelType _gradientStart; 
00318     PixelType _gradientEnd; 
00320     int _gradientBytes[3]; 
00322     Common::Array<PixelType> _gradCache;
00323     Common::Array<int> _gradIndexes;
00324 
00325     PixelType _bevelColor;
00326     PixelType _bitmapAlphaColor;
00327 };
00328 
00329 
00330 #ifndef DISABLE_FANCY_THEMES
00331 
00343 template<typename PixelType>
00344 class VectorRendererAA : public VectorRendererSpec<PixelType> {
00345     typedef VectorRendererSpec<PixelType> Base;
00346 public:
00347     VectorRendererAA(PixelFormat format) : VectorRendererSpec<PixelType>(format) {
00348     }
00349 
00350 protected:
00360     virtual void drawLineAlg(int x1, int y1, int x2, int y2, uint dx, uint dy, PixelType color);
00361 
00371     virtual void drawCircleAlg(int x, int y, int r, PixelType color, VectorRenderer::FillMode fill_m);
00372 
00380     virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m);
00381 
00382     virtual void drawBorderRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m, uint8 alpha_t, uint8 alpha_l, uint8 alpha_r, uint8 alpha_b);
00383 
00384     virtual void drawInteriorRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m);
00385 
00386     virtual void drawRoundedSquareShadow(int x, int y, int r, int w, int h, int offset) {
00387         Base::drawRoundedSquareShadow(x, y, r, w, h, offset);
00388     }
00389 
00390     virtual void drawTabAlg(int x, int y, int w, int h, int r,
00391         PixelType color, VectorRenderer::FillMode fill_m,
00392         int baseLeft = 0, int baseRight = 0);
00393 };
00394 #endif
00395 
00396 }
00397 #endif


Generated on Sat Feb 23 2019 05:01:20 for ResidualVM by doxygen 1.7.1
curved edge   curved edge