diff options
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/VectorRenderer.cpp | 86 | ||||
-rw-r--r-- | graphics/VectorRenderer.h | 81 |
2 files changed, 87 insertions, 80 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 diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h index ee8129bd67..a5e80164be 100644 --- a/graphics/VectorRenderer.h +++ b/graphics/VectorRenderer.h @@ -338,86 +338,9 @@ public: _gradientFactor = factor; } - void 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; - } - } - - int stepGetRadius(const DrawStep &step, const Common::Rect &area) { - int radius = 0; + void stepGetPositions(const DrawStep &step, const Common::Rect &area, uint16 &in_x, uint16 &in_y, uint16 &in_w, uint16 &in_h); - 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; - } + int stepGetRadius(const DrawStep &step, const Common::Rect &area); /** * DrawStep callback functions for each drawing feature |