[Scummvm-git-logs] scummvm master -> a2b77e9faa4e391896fe9fdcfcb84b08d96e2b3c
OMGPizzaGuy
noreply at scummvm.org
Fri Dec 23 05:57:09 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
a2b77e9faa ULTIMA8: Replace render surface draw line implementation and use in minimap
Commit: a2b77e9faa4e391896fe9fdcfcb84b08d96e2b3c
https://github.com/scummvm/scummvm/commit/a2b77e9faa4e391896fe9fdcfcb84b08d96e2b3c
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2022-12-22T23:56:39-06:00
Commit Message:
ULTIMA8: Replace render surface draw line implementation and use in minimap
Changed paths:
engines/ultima/ultima8/graphics/render_surface.cpp
engines/ultima/ultima8/gumps/minimap_gump.cpp
diff --git a/engines/ultima/ultima8/graphics/render_surface.cpp b/engines/ultima/ultima8/graphics/render_surface.cpp
index 4b0d861f9be..c45977c18db 100644
--- a/engines/ultima/ultima8/graphics/render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/render_surface.cpp
@@ -336,62 +336,8 @@ void RenderSurface::Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h) {
// Desc: Draw a (non-antialiased) line from (sx,sy) to (ex,ey) with color rgb
//
void RenderSurface::DrawLine32(uint32 rgb, int32 sx, int32 sy, int32 ex, int32 ey) {
- if (sy == ey) {
- int w;
- if (sx < ex) {
- w = ex - sx + 1;
- } else {
- w = sx - ex + 1;
- sx = ex;
- }
- Fill32(rgb, sx, sy, w, 1);
- } else if (sx == ex) {
- int h;
- if (sy < ey) {
- h = ey - sy + 1;
- } else {
- h = sy - ey + 1;
- sy = ey;
- }
- Fill32(rgb, sx, sy, 1, h);
- } else {
- int32 t;
- bool steep = ABS(ey - sy) > ABS(ex - sx);
- if (steep) {
- t = sx;
- sx = sy;
- sy = t;
- t = ex;
- ex = ey;
- ey = t;
- }
- if (sx > ex) {
- t = sx;
- sx = ex;
- ex = t;
- t = sy;
- sy = ey;
- ey = t;
- }
- int deltax = ex - sx;
- int deltay = ABS(ey - sy);
- int error = -deltax / 2;
- int y = sy;
- int ystep = (sy < ey) ? 1 : -1;
- for (int x = sx; x <= ex; ++x) {
- // TODO: don't use Fill32 here; it's too slow
- if (steep) {
- Fill32(rgb, y, x, 1, 1);
- } else {
- Fill32(rgb, x, y, 1, 1);
- }
- error += deltay;
- if (error > 0) {
- y += ystep;
- error -= deltax;
- }
- }
- }
+ rgb = _surface->format.RGBToColor((rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, rgb & 0xFF);
+ _surface->drawLine(sx + _ox, sy + _oy, ex + _ox, ey + _oy, rgb);
}
//
diff --git a/engines/ultima/ultima8/gumps/minimap_gump.cpp b/engines/ultima/ultima8/gumps/minimap_gump.cpp
index a90e88c2a40..6b0a84fc9fe 100644
--- a/engines/ultima/ultima8/gumps/minimap_gump.cpp
+++ b/engines/ultima/ultima8/gumps/minimap_gump.cpp
@@ -114,10 +114,10 @@ void MiniMapGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled)
color = HIGHLIGHT_COLOR;
// Draw the border
- surf->Fill32(color, 0, 0, _dims.width(), 1);
- surf->Fill32(color, 0, 1, 1, _dims.height());
- surf->Fill32(color, 1, _dims.bottom - 1, _dims.width(), 1);
- surf->Fill32(color, _dims.right - 1, 1, 1, _dims.height());
+ surf->DrawLine32(color, _dims.left, _dims.top, _dims.right - 1, _dims.top);
+ surf->DrawLine32(color, _dims.left, _dims.top, _dims.left, _dims.bottom - 1);
+ surf->DrawLine32(color, _dims.left, _dims.bottom - 1, _dims.right - 1, _dims.bottom - 1);
+ surf->DrawLine32(color, _dims.right -1, _dims.top, _dims.right - 1, _dims.bottom - 1);
// Dimensions minus border
Common::Rect dims(_dims.left, _dims.top, _dims.right, _dims.bottom);
@@ -169,10 +169,10 @@ void MiniMapGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled)
int32 ay = _ay - sy;
// Paint the avatar position marker
- surf->Fill32(color, 1 + ax - 2, 1 + ay + 0, 2, 1);
- surf->Fill32(color, 1 + ax + 0, 1 + ay - 2, 1, 2);
- surf->Fill32(color, 1 + ax + 1, 1 + ay + 0, 2, 1);
- surf->Fill32(color, 1 + ax + 0, 1 + ay + 1, 1, 2);
+ surf->DrawLine32(color, ax - 1, ay + 1, ax, ay + 1);
+ surf->DrawLine32(color, ax + 1, ay - 1, ax + 1, ay);
+ surf->DrawLine32(color, ax + 2, ay + 1, ax + 3, ay + 1);
+ surf->DrawLine32(color, ax + 1, ay + 2, ax + 1, ay + 3);
}
Gump *MiniMapGump::onMouseDown(int button, int32 mx, int32 my) {
More information about the Scummvm-git-logs
mailing list