aboutsummaryrefslogtreecommitdiff
path: root/graphics/VectorRenderer.cpp
diff options
context:
space:
mode:
authorVicent Marti2008-07-21 19:42:35 +0000
committerVicent Marti2008-07-21 19:42:35 +0000
commitc7b624d91eaa0444fdc454dfb5c5dd7beaa56bcc (patch)
tree17a6cc5a1da1847471cf7d77362166e0cad91cd1 /graphics/VectorRenderer.cpp
parent0883615a23d4ecb3fcc6296668a6c86173617810 (diff)
downloadscummvm-rg350-c7b624d91eaa0444fdc454dfb5c5dd7beaa56bcc.tar.gz
scummvm-rg350-c7b624d91eaa0444fdc454dfb5c5dd7beaa56bcc.tar.bz2
scummvm-rg350-c7b624d91eaa0444fdc454dfb5c5dd7beaa56bcc.zip
Bugfix: Rounded squares at low resolutions were not drawn.
Cleanup. svn-id: r33179
Diffstat (limited to 'graphics/VectorRenderer.cpp')
-rw-r--r--graphics/VectorRenderer.cpp86
1 files changed, 85 insertions, 1 deletions
diff --git a/graphics/VectorRenderer.cpp b/graphics/VectorRenderer.cpp
index 190bbbb40a..9b460e1ac0 100644
--- a/graphics/VectorRenderer.cpp
+++ b/graphics/VectorRenderer.cpp
@@ -84,6 +84,87 @@ void VectorRenderer::textStep(const Common::String &text, const Common::Rect &ar
!step.hasAlign ? GUI::Theme::kTextAlignVTop : step.alignVertical);
}
+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;
+
+ 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;
+
+ case Graphics::DrawStep::kVectorAlignCenter:
+ in_x = area.left + (area.width() / 2) - (in_w / 2);
+ break;
+
+ case Graphics::DrawStep::kVectorAlignLeft:
+ in_x = area.left;
+ break;
+
+ case Graphics::DrawStep::kVectorAlignRight:
+ in_x = area.left + area.width() - in_w;
+ break;
+
+ default:
+ error("Vertical alignment in horizontal data.");
+ }
+ } else {
+ in_x = area.left;
+ in_w = area.width();
+ }
+
+ if (!step.autoHeight) {
+ in_h = step.h == -1 ? area.width() : step.h;
+
+ 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;
+
+ case Graphics::DrawStep::kVectorAlignCenter:
+ in_y = area.top + (area.height() / 2) - (in_h / 2);
+ break;
+
+ case Graphics::DrawStep::kVectorAlignTop:
+ in_y = area.top;
+ break;
+
+ case Graphics::DrawStep::kVectorAlignBottom:
+ in_y = area.top + area.height() - in_h;
+ break;
+
+ 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;
+ }
+}
+
/********************************************************************
* MISCELANEOUS functions
********************************************************************/
@@ -356,8 +437,11 @@ template<typename PixelType, typename PixelFormat>
void VectorRendererSpec<PixelType, PixelFormat>::
drawRoundedSquare(int x, int y, int r, int w, int h) {
if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h ||
- w <= 0 || h <= 0 || x < 0 || y < 0 || (r << 1) > w || (r << 1) > h)
+ w <= 0 || h <= 0 || x < 0 || y < 0)
return;
+
+ while ((r << 1) > w || (r << 1) > h)
+ r <<= 1;
if (Base::_fillMode != kFillDisabled && Base::_shadowOffset
&& x + w + Base::_shadowOffset < Base::_activeSurface->w