2008-05-01 23:50:14 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
2008-05-01 23:58:05 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
2008-05-01 23:50:14 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/util.h"
|
2008-05-02 17:53:21 +00:00
|
|
|
#include "common/system.h"
|
2008-05-06 09:54:10 +00:00
|
|
|
#include "common/events.h"
|
2008-05-01 23:50:14 +00:00
|
|
|
|
2008-05-28 14:27:22 +00:00
|
|
|
#include "graphics/surface.h"
|
|
|
|
#include "graphics/colormasks.h"
|
|
|
|
|
2008-09-02 17:51:08 +00:00
|
|
|
#include "gui/ThemeEngine.h"
|
2008-05-18 13:09:37 +00:00
|
|
|
#include "graphics/VectorRenderer.h"
|
2008-05-16 20:40:24 +00:00
|
|
|
|
2008-07-13 22:25:11 +00:00
|
|
|
#define VECTOR_RENDERER_FAST_TRIANGLES
|
|
|
|
|
2008-05-16 20:40:24 +00:00
|
|
|
namespace Graphics {
|
2008-05-03 19:50:38 +00:00
|
|
|
|
2008-05-26 18:17:03 +00:00
|
|
|
/********************************************************************
|
|
|
|
* DRAWSTEP handling functions
|
|
|
|
********************************************************************/
|
2008-07-17 08:36:16 +00:00
|
|
|
void VectorRenderer::drawStep(const Common::Rect &area, const DrawStep &step, uint32 extra) {
|
2008-05-26 18:17:03 +00:00
|
|
|
|
2008-06-18 00:15:21 +00:00
|
|
|
if (step.bgColor.set)
|
2008-06-16 23:38:21 +00:00
|
|
|
setBgColor(step.bgColor.r, step.bgColor.g, step.bgColor.b);
|
2008-05-26 18:17:03 +00:00
|
|
|
|
2008-06-18 00:15:21 +00:00
|
|
|
if (step.fgColor.set)
|
2008-06-16 23:38:21 +00:00
|
|
|
setFgColor(step.fgColor.r, step.fgColor.g, step.fgColor.b);
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-08-04 16:59:55 +00:00
|
|
|
if (step.bevelColor.set)
|
|
|
|
setBevelColor(step.bevelColor.r, step.bevelColor.g, step.bevelColor.b);
|
2008-05-26 18:17:03 +00:00
|
|
|
|
2008-06-18 00:15:21 +00:00
|
|
|
if (step.gradColor1.set && step.gradColor2.set)
|
2008-12-22 11:22:15 +00:00
|
|
|
setGradientColors(step.gradColor1.r, step.gradColor1.g, step.gradColor1.b,
|
2008-06-16 23:38:21 +00:00
|
|
|
step.gradColor2.r, step.gradColor2.g, step.gradColor2.b);
|
2008-05-26 18:17:03 +00:00
|
|
|
|
2008-07-20 21:47:28 +00:00
|
|
|
setShadowOffset(_disableShadows ? 0 : step.shadow);
|
2008-08-04 16:59:55 +00:00
|
|
|
setBevel(step.bevel);
|
2008-06-18 00:15:21 +00:00
|
|
|
setGradientFactor(step.factor);
|
|
|
|
setStrokeWidth(step.stroke);
|
|
|
|
setFillMode((FillMode)step.fillMode);
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-17 08:36:16 +00:00
|
|
|
_dynamicData = extra;
|
2008-05-26 18:17:03 +00:00
|
|
|
|
2008-07-17 08:36:16 +00:00
|
|
|
(this->*(step.drawingCall))(area, step);
|
2008-05-26 18:17:03 +00:00
|
|
|
}
|
|
|
|
|
2008-07-21 19:42:35 +00:00
|
|
|
int VectorRenderer::stepGetRadius(const DrawStep &step, const Common::Rect &area) {
|
|
|
|
int radius = 0;
|
|
|
|
|
|
|
|
if (step.radius == 0xFF)
|
|
|
|
radius = MIN(area.width(), area.height()) / 2;
|
|
|
|
else
|
|
|
|
radius = step.radius;
|
|
|
|
|
|
|
|
if (step.scale != (1 << 16) && step.scale != 0)
|
|
|
|
radius = (radius * step.scale) >> 16;
|
|
|
|
|
|
|
|
return radius;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VectorRenderer::stepGetPositions(const DrawStep &step, const Common::Rect &area, uint16 &in_x, uint16 &in_y, uint16 &in_w, uint16 &in_h) {
|
|
|
|
if (!step.autoWidth) {
|
|
|
|
in_w = step.w == -1 ? area.height() : step.w;
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-21 19:42:35 +00:00
|
|
|
switch(step.xAlign) {
|
|
|
|
case Graphics::DrawStep::kVectorAlignManual:
|
|
|
|
if (step.x >= 0) in_x = area.left + step.x;
|
|
|
|
else in_x = area.left + area.width() + step.x; // value relative to the opposite corner.
|
|
|
|
break;
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-21 19:42:35 +00:00
|
|
|
case Graphics::DrawStep::kVectorAlignCenter:
|
2008-12-22 11:22:15 +00:00
|
|
|
in_x = area.left + (area.width() / 2) - (in_w / 2);
|
2008-07-21 19:42:35 +00:00
|
|
|
break;
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-21 19:42:35 +00:00
|
|
|
case Graphics::DrawStep::kVectorAlignLeft:
|
|
|
|
in_x = area.left;
|
|
|
|
break;
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-21 19:42:35 +00:00
|
|
|
case Graphics::DrawStep::kVectorAlignRight:
|
|
|
|
in_x = area.left + area.width() - in_w;
|
|
|
|
break;
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-21 19:42:35 +00:00
|
|
|
default:
|
|
|
|
error("Vertical alignment in horizontal data.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
in_x = area.left;
|
|
|
|
in_w = area.width();
|
|
|
|
}
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-21 19:42:35 +00:00
|
|
|
if (!step.autoHeight) {
|
|
|
|
in_h = step.h == -1 ? area.width() : step.h;
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-21 19:42:35 +00:00
|
|
|
switch(step.yAlign) {
|
|
|
|
case Graphics::DrawStep::kVectorAlignManual:
|
|
|
|
if (step.y >= 0) in_y = area.top + step.y;
|
|
|
|
else in_y = area.top + area.height() + step.y; // relative
|
|
|
|
break;
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-21 19:42:35 +00:00
|
|
|
case Graphics::DrawStep::kVectorAlignCenter:
|
2008-12-22 11:22:15 +00:00
|
|
|
in_y = area.top + (area.height() / 2) - (in_h / 2);
|
2008-07-21 19:42:35 +00:00
|
|
|
break;
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-21 19:42:35 +00:00
|
|
|
case Graphics::DrawStep::kVectorAlignTop:
|
|
|
|
in_y = area.top;
|
|
|
|
break;
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-21 19:42:35 +00:00
|
|
|
case Graphics::DrawStep::kVectorAlignBottom:
|
|
|
|
in_y = area.top + area.height() - in_h;
|
|
|
|
break;
|
2008-12-22 11:22:15 +00:00
|
|
|
|
2008-07-21 19:42:35 +00:00
|
|
|
default:
|
|
|
|
error("Horizontal alignment in vertical data.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
in_y = area.top;
|
|
|
|
in_h = area.height();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (step.scale != (1 << 16) && step.scale != 0) {
|
|
|
|
in_x = (in_x * step.scale) >> 16;
|
|
|
|
in_y = (in_y * step.scale) >> 16;
|
|
|
|
in_w = (in_w * step.scale) >> 16;
|
|
|
|
in_h = (in_h * step.scale) >> 16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-17 16:45:28 +00:00
|
|
|
} // end of namespace Graphics
|