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 drawCircle(int x, int y, int r);
00055     void drawSquare(int x, int y, int w, int h);
00056     void drawRoundedSquare(int x, int y, int r, int w, int h);
00057     void drawTriangle(int x, int y, int base, int height, TriangleOrientation orient);
00058     void drawTab(int x, int y, int r, int w, int h);
00059 
00060     void drawBeveledSquare(int x, int y, int w, int h) {
00061         bool useClippingVersions = !_clippingArea.contains(Common::Rect(x, y, x + w, y + h));
00062         if (useClippingVersions) {
00063             drawBevelSquareAlgClip(x, y, w, h, _bevel, _bevelColor, _fgColor);
00064         } else {
00065             drawBevelSquareAlg(x, y, w, h, _bevel, _bevelColor, _fgColor);
00066         }
00067     }
00068     void drawString(const Graphics::Font *font, const Common::String &text,
00069                     const Common::Rect &area, Graphics::TextAlign alignH,
00070                     GUI::ThemeEngine::TextAlignVertical alignV, int deltax, bool elipsis, const Common::Rect &textDrawableArea = Common::Rect(0, 0, 0, 0));
00071 
00072     void setFgColor(uint8 r, uint8 g, uint8 b) { _fgColor = _format.RGBToColor(r, g, b); }
00073     void setBgColor(uint8 r, uint8 g, uint8 b) { _bgColor = _format.RGBToColor(r, g, b); }
00074     void setBevelColor(uint8 r, uint8 g, uint8 b) { _bevelColor = _format.RGBToColor(r, g, b); }
00075     void setGradientColors(uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2);
00076     void setClippingRect(const Common::Rect &clippingArea) override { _clippingArea = clippingArea; }
00077 
00078     void copyFrame(OSystem *sys, const Common::Rect &r);
00079     void copyWholeFrame(OSystem *sys) { copyFrame(sys, Common::Rect(0, 0, _activeSurface->w, _activeSurface->h)); }
00080 
00081     void fillSurface();
00082     void blitSurface(const Graphics::Surface *source, const Common::Rect &r);
00083     void blitSubSurface(const Graphics::Surface *source, const Common::Point &p);
00084     void blitKeyBitmap(const Graphics::Surface *source, const Common::Point &p);
00085     void blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r,
00086             GUI::ThemeEngine::AutoScaleMode autoscale = GUI::ThemeEngine::kAutoScaleNone,
00087             Graphics::DrawStep::VectorAlignment xAlign = Graphics::DrawStep::kVectorAlignManual,
00088             Graphics::DrawStep::VectorAlignment yAlign = Graphics::DrawStep::kVectorAlignManual,
00089             int alpha = 255);
00090 
00091     void applyScreenShading(GUI::ThemeEngine::ShadingStyle shadingStyle);
00092 
00093 protected:
00094 
00095     Common::Rect _clippingArea;
00096 
00105     inline void putPixel(int x, int y, PixelType color) {
00106         PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x, y);
00107         *ptr = color;
00108     }
00109 
00119     inline void blendPixel(int x, int y, PixelType color, uint8 alpha) {
00120         blendPixelPtr((PixelType *)Base::_activeSurface->getBasePtr(x, y), color, alpha);
00121     }
00122 
00135     inline void blendPixelPtr(PixelType *ptr, PixelType color, uint8 alpha);
00136     inline void blendPixelPtrClip(PixelType *ptr, PixelType color, uint8 alpha, int x, int y);
00137 
00153     inline void blendPixelDestAlphaPtr(PixelType *ptr, PixelType color, uint8 alpha);
00154 
00155 
00167     virtual void drawLineAlg(int x1, int y1, int x2, int y2,
00168         uint dx, uint dy, PixelType color);
00169 
00170     virtual void drawLineAlgClip(int x1, int y1, int x2, int y2,
00171         uint dx, uint dy, PixelType color);
00172 
00173     virtual void drawCircleAlg(int x, int y, int r,
00174         PixelType color, FillMode fill_m);
00175 
00176     virtual void drawCircleAlgClip(int x, int y, int r,
00177         PixelType color, FillMode fill_m);
00178 
00179     virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h,
00180         PixelType color, FillMode fill_m);
00181 
00182     virtual void drawRoundedSquareAlgClip(int x1, int y1, int r, int w, int h,
00183         PixelType color, FillMode fill_m);
00184 
00185     virtual void drawBorderRoundedSquareAlg(int x1, int y1, int r, int w, int h,
00186         PixelType color, FillMode fill_m, uint8 alpha_t, uint8 alpha_r, uint8 alpha_b, uint8 alpha_l);
00187 
00188     virtual void drawBorderRoundedSquareAlgClip(int x1, int y1, int r, int w, int h,
00189         PixelType color, FillMode fill_m, uint8 alpha_t, uint8 alpha_r, uint8 alpha_b, uint8 alpha_l);
00190 
00191     virtual void drawInteriorRoundedSquareAlg(int x1, int y1, int r, int w, int h,
00192         PixelType color, FillMode fill_m);
00193 
00194     virtual void drawInteriorRoundedSquareAlgClip(int x1, int y1, int r, int w, int h,
00195         PixelType color, FillMode fill_m);
00196 
00197     virtual void drawSquareAlg(int x, int y, int w, int h,
00198         PixelType color, FillMode fill_m);
00199 
00200     virtual void drawSquareAlgClip(int x, int y, int w, int h,
00201         PixelType color, FillMode fill_m);
00202 
00203     virtual void drawTriangleVertAlg(int x, int y, int w, int h,
00204         bool inverted, PixelType color, FillMode fill_m);
00205 
00206     virtual void drawTriangleVertAlgClip(int x, int y, int w, int h,
00207         bool inverted, PixelType color, FillMode fill_m);
00208 
00209     virtual void drawTriangleFast(int x, int y, int size,
00210         bool inverted, PixelType color, FillMode fill_m);
00211 
00212     virtual void drawBevelSquareAlg(int x, int y, int w, int h,
00213         int bevel, PixelType top_color, PixelType bottom_color);
00214 
00215     virtual void drawBevelSquareAlgClip(int x, int y, int w, int h,
00216         int bevel, PixelType top_color, PixelType bottom_color);
00217 
00218     virtual void drawTabAlg(int x, int y, int w, int h, int r,
00219         PixelType color, VectorRenderer::FillMode fill_m,
00220         int baseLeft = 0, int baseRight = 0);
00221 
00222     virtual void drawTabAlgClip(int x, int y, int w, int h, int r,
00223         PixelType color, VectorRenderer::FillMode fill_m,
00224         int baseLeft = 0, int baseRight = 0);
00225 
00226     virtual void drawTabShadow(int x, int y, int w, int h, int r);
00227 
00228     virtual void drawTabShadowClip(int x, int y, int w, int h, int r);
00229 
00230     virtual void drawBevelTabAlg(int x, int y, int w, int h,
00231         int bevel, PixelType topColor, PixelType bottomColor,
00232         int baseLeft = 0, int baseRight = 0);
00233 
00234     virtual void drawBevelTabAlgClip(int x, int y, int w, int h,
00235         int bevel, PixelType topColor, PixelType bottomColor,
00236         int baseLeft = 0, int baseRight = 0);
00237 
00248     virtual void drawSquareShadow(int x, int y, int w, int h, int offset);
00249     virtual void drawSquareShadowClip(int x, int y, int w, int h, int offset);
00250     virtual void drawRoundedSquareShadow(int x, int y, int r, int w, int h, int offset);
00251     virtual void drawRoundedSquareShadowClip(int x, int y, int r, int w, int h, int offset);
00252 
00262     inline PixelType calcGradient(uint32 pos, uint32 max);
00263 
00264     void precalcGradient(int h);
00265     void gradientFill(PixelType *first, int width, int x, int y);
00266     void gradientFillClip(PixelType *first, int width, int x, int y, int realX, int realY);
00267 
00278     inline void blendFill(PixelType *first, PixelType *last, PixelType color, uint8 alpha) {
00279         while (first != last)
00280             blendPixelPtr(first++, color, alpha);
00281     }
00282 
00283     inline void blendFillClip(PixelType *first, PixelType *last, PixelType color, uint8 alpha, int realX, int realY) {
00284         if (_clippingArea.top <= realY && realY < _clippingArea.bottom) {
00285             while (first != last) {
00286                 if (_clippingArea.left <= realX && realX < _clippingArea.right)
00287                     blendPixelPtr(first++, color, alpha);
00288                 else
00289                     ++first;
00290                 ++realX;
00291             }
00292         }
00293     }
00294 
00295     void darkenFill(PixelType *first, PixelType *last);
00296     void darkenFillClip(PixelType *first, PixelType *last, int x, int y);
00297 
00298     const PixelFormat _format;
00299     const PixelType _redMask, _greenMask, _blueMask, _alphaMask;
00300 
00301     PixelType _fgColor; 
00302     PixelType _bgColor; 
00304     PixelType _gradientStart; 
00305     PixelType _gradientEnd; 
00307     int _gradientBytes[3]; 
00309     Common::Array<PixelType> _gradCache;
00310     Common::Array<int> _gradIndexes;
00311 
00312     PixelType _bevelColor;
00313     PixelType _bitmapAlphaColor;
00314 };
00315 
00316 
00317 #ifndef DISABLE_FANCY_THEMES
00318 
00330 template<typename PixelType>
00331 class VectorRendererAA : public VectorRendererSpec<PixelType> {
00332     typedef VectorRendererSpec<PixelType> Base;
00333 public:
00334     VectorRendererAA(PixelFormat format) : VectorRendererSpec<PixelType>(format) {
00335     }
00336 
00337 protected:
00347     virtual void drawLineAlg(int x1, int y1, int x2, int y2, uint dx, uint dy, PixelType color);
00348 
00358     virtual void drawCircleAlg(int x, int y, int r, PixelType color, VectorRenderer::FillMode fill_m);
00359 
00367     virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m);
00368 
00369     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);
00370 
00371     virtual void drawInteriorRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m);
00372 
00373     virtual void drawRoundedSquareShadow(int x, int y, int r, int w, int h, int offset) {
00374         Base::drawRoundedSquareShadow(x, y, r, w, h, offset);
00375     }
00376 
00377     virtual void drawTabAlg(int x, int y, int w, int h, int r,
00378         PixelType color, VectorRenderer::FillMode fill_m,
00379         int baseLeft = 0, int baseRight = 0);
00380 };
00381 #endif
00382 
00383 }
00384 #endif


Generated on Sat Apr 4 2020 05:00:36 for ResidualVM by doxygen 1.7.1
curved edge   curved edge