[Scummvm-git-logs] scummvm master -> c979adcc4888e8e23dc17eac33bc137291bf781c
dreammaster
paulfgilbert at gmail.com
Mon Jun 8 02:12:32 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0730c17a4d GLK: COMPREHEND: Splitting floodfill into it's own class
c979adcc48 GLK: COMPREHEND: Fix text character rendering
Commit: 0730c17a4d0f0f604e579a020ae7f94bb5a33cee
https://github.com/scummvm/scummvm/commit/0730c17a4d0f0f604e579a020ae7f94bb5a33cee
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-07T16:57:36-07:00
Commit Message:
GLK: COMPREHEND: Splitting floodfill into it's own class
The original floodfill code has several specific variables and
sub-methods, so it'll be cleaner to encapsulate them together
in their own class
Changed paths:
engines/glk/comprehend/draw_surface.cpp
engines/glk/comprehend/draw_surface.h
diff --git a/engines/glk/comprehend/draw_surface.cpp b/engines/glk/comprehend/draw_surface.cpp
index d8daae135b..d8d81a7980 100644
--- a/engines/glk/comprehend/draw_surface.cpp
+++ b/engines/glk/comprehend/draw_surface.cpp
@@ -28,7 +28,7 @@
namespace Glk {
namespace Comprehend {
-const uint32 DrawSurface::PEN_COLORS[8] = {
+const uint32 Surface::PEN_COLORS[8] = {
G_COLOR_BLACK,
RGB(0x00, 0x66, 0x00),
RGB(0x00, 0xff, 0x00),
@@ -40,7 +40,7 @@ const uint32 DrawSurface::PEN_COLORS[8] = {
};
/* Used by Transylvania and Crimson Crown */
-const uint32 DrawSurface::DEFAULT_COLOR_TABLE[256] = {
+const uint32 Surface::DEFAULT_COLOR_TABLE[256] = {
G_COLOR_WHITE, // 00
G_COLOR_DARK_BLUE, // 01
G_COLOR_GRAY1, // 02
@@ -86,7 +86,7 @@ const uint32 DrawSurface::DEFAULT_COLOR_TABLE[256] = {
/* Used by OO-topos */
/* FIXME - incomplete */
-const uint32 DrawSurface::COLOR_TABLE_1[256] = {
+const uint32 Surface::COLOR_TABLE_1[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -164,19 +164,19 @@ const uint32 DrawSurface::COLOR_TABLE_1[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
-const uint32 *DrawSurface::COLOR_TABLES[2] = {
+const uint32 *Surface::COLOR_TABLES[2] = {
DEFAULT_COLOR_TABLE,
COLOR_TABLE_1,
};
/*-------------------------------------------------------*/
-void DrawSurface::reset() {
+void Surface::reset() {
create(G_RENDER_WIDTH, G_RENDER_HEIGHT,
Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
}
-void DrawSurface::setColorTable(uint index) {
+void Surface::setColorTable(uint index) {
if (index >= ARRAY_SIZE(COLOR_TABLES)) {
warning("Bad color table %d - using default", index);
_colorTable = DEFAULT_COLOR_TABLE;
@@ -185,11 +185,11 @@ void DrawSurface::setColorTable(uint index) {
_colorTable = COLOR_TABLES[index];
}
-uint DrawSurface::getPenColor(uint8 param) const {
+uint Surface::getPenColor(uint8 param) const {
return PEN_COLORS[param];
}
-uint32 DrawSurface::getFillColor(uint8 index) {
+uint32 Surface::getFillColor(uint8 index) {
unsigned color;
color = _colorTable[index];
@@ -202,7 +202,7 @@ uint32 DrawSurface::getFillColor(uint8 index) {
return color;
}
-void DrawSurface::drawLine(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color) {
+void Surface::drawLine(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color) {
#if 1
Graphics::ManagedSurface::drawLine(x1, y1, x2, y2, color);
#else
@@ -254,17 +254,17 @@ void DrawSurface::drawLine(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color)
#endif
}
-void DrawSurface::drawBox(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color) {
+void Surface::drawBox(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color) {
Common::Rect r(x1, y1, x2 + 1, y2 + 1);
frameRect(r, color);
}
-void DrawSurface::drawFilledBox(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color) {
+void Surface::drawFilledBox(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color) {
Common::Rect r(x1, y1, x2 + 1, y2 + 1);
fillRect(r, color);
}
-void DrawSurface::drawShape(int16 x, int16 y, int shape_type, uint32 fill_color) {
+void Surface::drawShape(int16 x, int16 y, int shape_type, uint32 fill_color) {
int i, j;
switch (shape_type) {
@@ -370,72 +370,24 @@ void DrawSurface::drawShape(int16 x, int16 y, int shape_type, uint32 fill_color)
}
}
-void DrawSurface::floodFill(int16 x, int16 y, uint32 fillColor) {
- int x1, x2, i;
-
- if (y == this->h)
- y = this->h - 1;
- else if (y > this->h)
- return;
-
- if (!isPixelWhite(x, y))
- return;
-
- // Left end of scanline
- for (x1 = x; x1 > 0; x1--)
- if (!isPixelWhite(x1 - 1, y))
- break;
-
- // Right end of scanline
- for (x2 = x; x2 < this->w; x2++)
- if (!isPixelWhite(x2 + 1, y))
- break;
-
- drawLine(x1, y, x2, y, fillColor);
-
- // Scanline above
- if (y > 0) {
- for (i = x1; i < x2; i++)
- if (isPixelWhite(i, y - 1))
- floodFill(i, y - 1, fillColor);
- }
-
- // Scanline below
- if (y < (this->h - 1)) {
- for (i = x1; i < x2; i++)
- if (isPixelWhite(i, y + 1))
- floodFill(i, y + 1, fillColor);
- }
-}
-
-void DrawSurface::drawPixel(int16 x, int16 y, uint32 color) {
+void Surface::drawPixel(int16 x, int16 y, uint32 color) {
if (x >= 0 && y >= 0 && x < this->w && y < this->h) {
uint32 *ptr = (uint32 *)getBasePtr(x, y);
*ptr = color;
}
}
-uint32 DrawSurface::getPixelColor(int16 x, int16 y) const {
+uint32 Surface::getPixelColor(int16 x, int16 y) const {
assert(x >= 0 && y >= 0 && x < this->w && y < this->h);
const uint32 *ptr = (uint32 *)getBasePtr(x, y);
return *ptr;
}
-bool DrawSurface::isPixelWhite(int16 x, int16 y) const {
- if (x < 0 || y < 0 || x >= this->w || y >= this->h) {
- return false;
- } else {
- byte r, g, b;
- format.colorToRGB(getPixelColor(x, y), r, g, b);
- return r == 255 && g == 255 && b == 255;
- }
-}
-
-void DrawSurface::clearScreen(uint32 color) {
+void Surface::clearScreen(uint32 color) {
fillRect(Common::Rect(0, 0, this->w, this->h), color);
}
-void DrawSurface::drawCircle(int16 x, int16 y, int16 diameter, uint32 color) {
+void Surface::drawCircle(int16 x, int16 y, int16 diameter, uint32 color) {
int invert = -diameter;
int delta = 0;
@@ -462,5 +414,55 @@ void DrawSurface::drawCircle(int16 x, int16 y, int16 diameter, uint32 color) {
} while (diameter >= delta);
}
+/*--------------------------------------------------------------------------*/
+
+bool FloodFillSurface::isPixelWhite(int16 x, int16 y) const {
+ if (x < 0 || y < 0 || x >= this->w || y >= this->h) {
+ return false;
+ } else {
+ byte r, g, b;
+ format.colorToRGB(getPixelColor(x, y), r, g, b);
+ return r == 255 && g == 255 && b == 255;
+ }
+}
+
+void FloodFillSurface::floodFill(int16 x, int16 y, uint32 fillColor) {
+ int x1, x2, i;
+
+ if (y == this->h)
+ y = this->h - 1;
+ else if (y > this->h)
+ return;
+
+ if (!isPixelWhite(x, y))
+ return;
+
+ // Left end of scanline
+ for (x1 = x; x1 > 0; x1--)
+ if (!isPixelWhite(x1 - 1, y))
+ break;
+
+ // Right end of scanline
+ for (x2 = x; x2 < this->w; x2++)
+ if (!isPixelWhite(x2 + 1, y))
+ break;
+
+ drawLine(x1, y, x2, y, fillColor);
+
+ // Scanline above
+ if (y > 0) {
+ for (i = x1; i < x2; i++)
+ if (isPixelWhite(i, y - 1))
+ floodFill(i, y - 1, fillColor);
+ }
+
+ // Scanline below
+ if (y < (this->h - 1)) {
+ for (i = x1; i < x2; i++)
+ if (isPixelWhite(i, y + 1))
+ floodFill(i, y + 1, fillColor);
+ }
+}
+
} // namespace Comprehend
} // namespace Glk
diff --git a/engines/glk/comprehend/draw_surface.h b/engines/glk/comprehend/draw_surface.h
index a5568e1119..635c0b1948 100644
--- a/engines/glk/comprehend/draw_surface.h
+++ b/engines/glk/comprehend/draw_surface.h
@@ -63,7 +63,7 @@ namespace Comprehend {
#define G_COLOR_BROWN1 0x7a5200ff
#define G_COLOR_BROWN2 0x663300ff
-class DrawSurface : public Graphics::ManagedSurface {
+class Surface : public Graphics::ManagedSurface {
private:
static const uint32 PEN_COLORS[8];
static const uint32 DEFAULT_COLOR_TABLE[256];
@@ -73,7 +73,7 @@ private:
public:
const uint32 *_colorTable;
public:
- DrawSurface() : _colorTable(DEFAULT_COLOR_TABLE) {
+ Surface() : _colorTable(DEFAULT_COLOR_TABLE) {
reset();
}
@@ -90,15 +90,23 @@ public:
void drawBox(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color);
void drawFilledBox(int16 x1, int16 y1, int16 x2, int16 y2, uint32 color);
void drawShape(int16 x, int16 y, int shape_type, uint32 fill_color);
- void floodFill(int16 x, int16 y, uint32 fillColor);
void drawPixel(int16 x, int16 y, uint32 color);
uint32 getPixelColor(int16 x, int16 y) const;
- bool isPixelWhite(int16 x, int16 y) const;
void clearScreen(uint32 color);
void drawCircle(int16 x, int16 y, int16 diameter, uint32 color);
void drawCirclePoint(int16 x, int16 y);
};
+class FloodFillSurface : public Surface {
+private:
+ bool isPixelWhite(int16 x, int16 y) const;
+public:
+ void floodFill(int16 x, int16 y, uint32 fillColor);
+};
+
+class DrawSurface : public FloodFillSurface {
+};
+
} // namespace Comprehend
} // namespace Glk
Commit: c979adcc4888e8e23dc17eac33bc137291bf781c
https://github.com/scummvm/scummvm/commit/c979adcc4888e8e23dc17eac33bc137291bf781c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-07T19:12:19-07:00
Commit Message:
GLK: COMPREHEND: Fix text character rendering
Changed paths:
engines/glk/comprehend/charset.cpp
diff --git a/engines/glk/comprehend/charset.cpp b/engines/glk/comprehend/charset.cpp
index ba46485b27..d17cbef3f2 100644
--- a/engines/glk/comprehend/charset.cpp
+++ b/engines/glk/comprehend/charset.cpp
@@ -54,8 +54,8 @@ void CharSet::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32
uint32 *lineP = (uint32 *)dst->getBasePtr(x, y + yp);
byte bits = _data[chr - 32][yp];
- for (uint xp = 0; xp < 8; ++xp, ++lineP, ++x, bits >>= 1) {
- if ((x >= 0) && (x < dst->w) && (bits & 1))
+ for (int xp = x; xp < (x + 8); ++xp, ++lineP, bits >>= 1) {
+ if ((xp >= 0) && (xp < dst->w) && (bits & 1))
*lineP = color;
}
}
More information about the Scummvm-git-logs
mailing list