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

VectorRenderer.cpp

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 #include "common/textconsole.h"
00024 #include "common/util.h"
00025 
00026 #include "graphics/VectorRenderer.h"
00027 
00028 #define VECTOR_RENDERER_FAST_TRIANGLES
00029 
00030 namespace Graphics {
00031 
00032 /********************************************************************
00033  * DRAWSTEP handling functions
00034  ********************************************************************/
00035 void VectorRenderer::drawStep(const Common::Rect &area, const DrawStep &step, uint32 extra) {
00036 
00037     if (step.bgColor.set)
00038         setBgColor(step.bgColor.r, step.bgColor.g, step.bgColor.b);
00039 
00040     if (step.fgColor.set)
00041         setFgColor(step.fgColor.r, step.fgColor.g, step.fgColor.b);
00042 
00043     if (step.bevelColor.set)
00044         setBevelColor(step.bevelColor.r, step.bevelColor.g, step.bevelColor.b);
00045 
00046     if (step.gradColor1.set && step.gradColor2.set)
00047         setGradientColors(step.gradColor1.r, step.gradColor1.g, step.gradColor1.b,
00048                           step.gradColor2.r, step.gradColor2.g, step.gradColor2.b);
00049 
00050     setShadowOffset(_disableShadows ? 0 : step.shadow);
00051     setBevel(step.bevel);
00052     setGradientFactor(step.factor);
00053     setStrokeWidth(step.stroke);
00054     setFillMode((FillMode)step.fillMode);
00055 
00056     _dynamicData = extra;
00057 
00058     Common::Rect noClip = Common::Rect(0, 0, 0, 0);
00059     (this->*(step.drawingCall))(area, step, noClip);
00060 }
00061 
00062 void VectorRenderer::drawStepClip(const Common::Rect &area, const Common::Rect &clip, const DrawStep &step, uint32 extra) {
00063 
00064     if (step.bgColor.set)
00065         setBgColor(step.bgColor.r, step.bgColor.g, step.bgColor.b);
00066 
00067     if (step.fgColor.set)
00068         setFgColor(step.fgColor.r, step.fgColor.g, step.fgColor.b);
00069 
00070     if (step.bevelColor.set)
00071         setBevelColor(step.bevelColor.r, step.bevelColor.g, step.bevelColor.b);
00072 
00073     if (step.gradColor1.set && step.gradColor2.set)
00074         setGradientColors(step.gradColor1.r, step.gradColor1.g, step.gradColor1.b,
00075             step.gradColor2.r, step.gradColor2.g, step.gradColor2.b);
00076 
00077     setShadowOffset(_disableShadows ? 0 : step.shadow);
00078     setBevel(step.bevel);
00079     setGradientFactor(step.factor);
00080     setStrokeWidth(step.stroke);
00081     setFillMode((FillMode)step.fillMode);
00082 
00083     _dynamicData = extra;
00084 
00085     (this->*(step.drawingCall))(area, step, clip);
00086 }
00087 
00088 int VectorRenderer::stepGetRadius(const DrawStep &step, const Common::Rect &area) {
00089     int radius = 0;
00090 
00091     if (step.radius == 0xFF)
00092         radius = MIN(area.width(), area.height()) / 2;
00093     else
00094         radius = step.radius;
00095 
00096     if (step.scale != (1 << 16) && step.scale != 0)
00097         radius = (radius * step.scale) >> 16;
00098 
00099     return radius;
00100 }
00101 
00102 void VectorRenderer::stepGetPositions(const DrawStep &step, const Common::Rect &area, uint16 &in_x, uint16 &in_y, uint16 &in_w, uint16 &in_h) {
00103     if (!step.autoWidth) {
00104         in_w = step.w == -1 ? area.height() : step.w;
00105 
00106         switch (step.xAlign) {
00107         case Graphics::DrawStep::kVectorAlignManual:
00108             if (step.x >= 0)
00109                 in_x = area.left + step.x + step.padding.left;
00110             else
00111                 in_x = area.left + area.width() + step.x + step.padding.left; // value relative to the opposite corner.
00112             break;
00113 
00114         case Graphics::DrawStep::kVectorAlignCenter:
00115             in_x = area.left + (area.width() / 2) - (in_w / 2) + ((step.padding.left + step.padding.right ) / 2);
00116             break;
00117 
00118         case Graphics::DrawStep::kVectorAlignLeft:
00119             in_x = area.left  + step.padding.left;
00120             break;
00121 
00122         case Graphics::DrawStep::kVectorAlignRight:
00123             in_x = area.left + area.width() - in_w - step.padding.right;
00124             break;
00125 
00126         default:
00127             error("Vertical alignment in horizontal data");
00128         }
00129     } else {
00130         in_x = area.left + step.padding.left;
00131         in_w = area.width();
00132     }
00133 
00134     if (!step.autoHeight) {
00135         in_h = step.h == -1 ? area.width() : step.h;
00136 
00137         switch (step.yAlign) {
00138         case Graphics::DrawStep::kVectorAlignManual:
00139             if (step.y >= 0)
00140                 in_y = area.top + step.y + step.padding.top;
00141             else
00142                 in_y = area.top + area.height() + step.y + step.padding.top; // relative
00143             break;
00144 
00145         case Graphics::DrawStep::kVectorAlignCenter:
00146             in_y = area.top + (area.height() / 2) - (in_h / 2) + ((step.padding.top + step.padding.bottom ) / 2);
00147             break;
00148 
00149         case Graphics::DrawStep::kVectorAlignTop:
00150             in_y = area.top + step.padding.top;
00151             break;
00152 
00153         case Graphics::DrawStep::kVectorAlignBottom:
00154             in_y = area.top + area.height() - in_h - step.padding.bottom;
00155             break;
00156 
00157         default:
00158             error("Horizontal alignment in vertical data");
00159         }
00160     } else {
00161         in_y = area.top + step.padding.top;
00162         in_h = area.height();
00163     }
00164 
00165     if (step.scale != (1 << 16) && step.scale != 0) {
00166         in_x = (in_x * step.scale) >> 16;
00167         in_y = (in_y * step.scale) >> 16;
00168         in_w = (in_w * step.scale) >> 16;
00169         in_h = (in_h * step.scale) >> 16;
00170     }
00171 }
00172 
00173 } // End of namespace Graphics


Generated on Sat May 25 2019 05:00:56 for ResidualVM by doxygen 1.7.1
curved edge   curved edge