Speech bubbles can point down right.
[scummvm-innocent.git] / graphics / VectorRenderer.cpp
blob2616664841864a86b09a155c8d5e7f08db81a893
1 /* ScummVM - Graphic Adventure Engine
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * $URL$
22 * $Id$
26 #include "common/util.h"
27 #include "common/system.h"
28 #include "common/events.h"
30 #include "graphics/surface.h"
31 #include "graphics/colormasks.h"
33 #include "gui/ThemeEngine.h"
34 #include "graphics/VectorRenderer.h"
36 #define VECTOR_RENDERER_FAST_TRIANGLES
38 namespace Graphics {
40 /********************************************************************
41 * DRAWSTEP handling functions
42 ********************************************************************/
43 void VectorRenderer::drawStep(const Common::Rect &area, const DrawStep &step, uint32 extra) {
45 if (step.bgColor.set)
46 setBgColor(step.bgColor.r, step.bgColor.g, step.bgColor.b);
48 if (step.fgColor.set)
49 setFgColor(step.fgColor.r, step.fgColor.g, step.fgColor.b);
51 if (step.bevelColor.set)
52 setBevelColor(step.bevelColor.r, step.bevelColor.g, step.bevelColor.b);
54 if (step.gradColor1.set && step.gradColor2.set)
55 setGradientColors(step.gradColor1.r, step.gradColor1.g, step.gradColor1.b,
56 step.gradColor2.r, step.gradColor2.g, step.gradColor2.b);
58 setShadowOffset(_disableShadows ? 0 : step.shadow);
59 setBevel(step.bevel);
60 setGradientFactor(step.factor);
61 setStrokeWidth(step.stroke);
62 setFillMode((FillMode)step.fillMode);
64 _dynamicData = extra;
66 (this->*(step.drawingCall))(area, step);
69 int VectorRenderer::stepGetRadius(const DrawStep &step, const Common::Rect &area) {
70 int radius = 0;
72 if (step.radius == 0xFF)
73 radius = MIN(area.width(), area.height()) / 2;
74 else
75 radius = step.radius;
77 if (step.scale != (1 << 16) && step.scale != 0)
78 radius = (radius * step.scale) >> 16;
80 return radius;
83 void VectorRenderer::stepGetPositions(const DrawStep &step, const Common::Rect &area, uint16 &in_x, uint16 &in_y, uint16 &in_w, uint16 &in_h) {
84 if (!step.autoWidth) {
85 in_w = step.w == -1 ? area.height() : step.w;
87 switch(step.xAlign) {
88 case Graphics::DrawStep::kVectorAlignManual:
89 if (step.x >= 0) in_x = area.left + step.x;
90 else in_x = area.left + area.width() + step.x; // value relative to the opposite corner.
91 break;
93 case Graphics::DrawStep::kVectorAlignCenter:
94 in_x = area.left + (area.width() / 2) - (in_w / 2);
95 break;
97 case Graphics::DrawStep::kVectorAlignLeft:
98 in_x = area.left;
99 break;
101 case Graphics::DrawStep::kVectorAlignRight:
102 in_x = area.left + area.width() - in_w;
103 break;
105 default:
106 error("Vertical alignment in horizontal data.");
108 } else {
109 in_x = area.left;
110 in_w = area.width();
113 if (!step.autoHeight) {
114 in_h = step.h == -1 ? area.width() : step.h;
116 switch(step.yAlign) {
117 case Graphics::DrawStep::kVectorAlignManual:
118 if (step.y >= 0) in_y = area.top + step.y;
119 else in_y = area.top + area.height() + step.y; // relative
120 break;
122 case Graphics::DrawStep::kVectorAlignCenter:
123 in_y = area.top + (area.height() / 2) - (in_h / 2);
124 break;
126 case Graphics::DrawStep::kVectorAlignTop:
127 in_y = area.top;
128 break;
130 case Graphics::DrawStep::kVectorAlignBottom:
131 in_y = area.top + area.height() - in_h;
132 break;
134 default:
135 error("Horizontal alignment in vertical data.");
137 } else {
138 in_y = area.top;
139 in_h = area.height();
142 if (step.scale != (1 << 16) && step.scale != 0) {
143 in_x = (in_x * step.scale) >> 16;
144 in_y = (in_y * step.scale) >> 16;
145 in_w = (in_w * step.scale) >> 16;
146 in_h = (in_h * step.scale) >> 16;
150 } // end of namespace Graphics