[Scummvm-git-logs] scummvm master -> 0b9055abf066d4f5ef0df48a690f38beb2994a19
bluegr
noreply at scummvm.org
Wed Jan 8 16:36:59 UTC 2025
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:
0b9055abf0 DIRECTOR: Migrate to the new Primitives class
Commit: 0b9055abf066d4f5ef0df48a690f38beb2994a19
https://github.com/scummvm/scummvm/commit/0b9055abf066d4f5ef0df48a690f38beb2994a19
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-01-08T18:36:55+02:00
Commit Message:
DIRECTOR: Migrate to the new Primitives class
Changed paths:
engines/director/director.cpp
engines/director/director.h
engines/director/graphics.cpp
engines/director/transitions.cpp
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index ef49735a1bb..b6ab75f803b 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -93,6 +93,7 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
_fixStageSize = false;
_fixStageRect = Common::Rect();
_wmMode = 0;
+ _primitives = nullptr;
_wmWidth = 1024;
_wmHeight = 768;
@@ -158,6 +159,7 @@ DirectorEngine::~DirectorEngine() {
delete _lingo;
delete _wm;
delete _surface;
+ delete _primitives;
for (auto &it : _allSeenResFiles) {
delete it._value;
diff --git a/engines/director/director.h b/engines/director/director.h
index 560c1b08621..44a79a48cd7 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -37,6 +37,7 @@ class SeekableReadStreamEndian;
}
namespace Graphics {
+class Primitives;
class MacWindowManager;
struct MacPlotData;
struct WinCursorGroup;
@@ -210,7 +211,7 @@ public:
void setCursor(DirectorCursor type);
void draw();
- Graphics::MacDrawPixPtr getInkDrawPixel();
+ Graphics::Primitives *getInkPrimitives();
uint32 getColorBlack();
uint32 getColorWhite();
@@ -312,6 +313,7 @@ private:
PaletteV4 _loaded4Palette;
Graphics::ManagedSurface *_surface;
+ Graphics::Primitives *_primitives;
StartOptions _options;
diff --git a/engines/director/graphics.cpp b/engines/director/graphics.cpp
index dea44bf9c7b..47d86e327c9 100644
--- a/engines/director/graphics.cpp
+++ b/engines/director/graphics.cpp
@@ -266,7 +266,14 @@ void DirectorEngine::draw() {
}
template <typename T>
-void inkDrawPixel(int x, int y, int src, void *data) {
+class InkPrimitives final : public Graphics::Primitives {
+public:
+ constexpr InkPrimitives() {}
+ void drawPoint(int x, int y, uint32 src, void *data) override;
+};
+
+template <typename T>
+void InkPrimitives<T>::drawPoint(int x, int y, uint32 src, void *data) {
DirectorPlotData *p = (DirectorPlotData *)data;
Graphics::MacWindowManager *wm = p->d->_wm;
@@ -291,7 +298,7 @@ void inkDrawPixel(int x, int y, int src, void *data) {
for (y = y1; y < y2; y++)
for (x = x1; x < x2; x++)
if (x >= 0 && x < p->ms->pd->surface->w && y >= 0 && y < p->ms->pd->surface->h) {
- inkDrawPixel<T>(x, y, src, data);
+ drawPoint(x, y, src, data);
}
p->ms->pd->thickness = prevThickness;
@@ -485,11 +492,15 @@ void inkDrawPixel(int x, int y, int src, void *data) {
}
}
-Graphics::MacDrawPixPtr DirectorEngine::getInkDrawPixel() {
- if (_pixelformat.bytesPerPixel == 1)
- return &inkDrawPixel<byte>;
- else
- return &inkDrawPixel<uint32>;
+Graphics::Primitives *DirectorEngine::getInkPrimitives() {
+ if (!_primitives) {
+ if (_pixelformat.bytesPerPixel == 1)
+ _primitives = new InkPrimitives<byte>();
+ else
+ _primitives = new InkPrimitives<uint32>();
+ }
+
+ return _primitives;
}
uint32 DirectorEngine::getColorBlack() {
@@ -619,10 +630,12 @@ void DirectorPlotData::inkBlitShape(Common::Rect &srcRect) {
strokeRect.moveTo(srcRect.left, srcRect.top);
Graphics::MacPlotData plotStroke(dst, nullptr, &d->getPatterns(), strokePattern, strokeRect.left + wpos.x, strokeRect.top + wpos.y, ms->lineSize, ms->backColor);
+ Graphics::Primitives *primitives = g_director->getInkPrimitives();
+
switch (ms->spriteType) {
case kRectangleSprite:
ms->pd = &plotFill;
- Graphics::drawFilledRect1(fillAreaRect, ms->foreColor, d->getInkDrawPixel(), this);
+ primitives->drawFilledRect1(fillAreaRect, ms->foreColor, this);
// fall through
case kOutlinedRectangleSprite:
// if we have lineSize <= 0, means we are not drawing anything. so we may return directly.
@@ -633,11 +646,11 @@ void DirectorPlotData::inkBlitShape(Common::Rect &srcRect) {
if (!outline)
ms->tile = nullptr;
- Graphics::drawRect1(strokeRect, ms->foreColor, d->getInkDrawPixel(), this);
+ primitives->drawRect1(strokeRect, ms->foreColor, this);
break;
case kRoundedRectangleSprite:
ms->pd = &plotFill;
- Graphics::drawRoundRect1(fillAreaRect, 12, ms->foreColor, true, d->getInkDrawPixel(), this);
+ primitives->drawRoundRect1(fillAreaRect, 12, ms->foreColor, true, this);
// fall through
case kOutlinedRoundedRectangleSprite:
if (ms->lineSize <= 0)
@@ -647,11 +660,11 @@ void DirectorPlotData::inkBlitShape(Common::Rect &srcRect) {
if (!outline)
ms->tile = nullptr;
- Graphics::drawRoundRect1(strokeRect, 12, ms->foreColor, false, d->getInkDrawPixel(), this);
+ primitives->drawRoundRect1(strokeRect, 12, ms->foreColor, false, this);
break;
case kOvalSprite:
ms->pd = &plotFill;
- Graphics::drawEllipse(fillAreaRect.left, fillAreaRect.top, fillAreaRect.right, fillAreaRect.bottom, ms->foreColor, true, d->getInkDrawPixel(), this);
+ primitives->drawEllipse(fillAreaRect.left, fillAreaRect.top, fillAreaRect.right, fillAreaRect.bottom, ms->foreColor, true, this);
// fall through
case kOutlinedOvalSprite:
if (ms->lineSize <= 0)
@@ -661,15 +674,15 @@ void DirectorPlotData::inkBlitShape(Common::Rect &srcRect) {
if (!outline)
ms->tile = nullptr;
- Graphics::drawEllipse(strokeRect.left, strokeRect.top, strokeRect.right, strokeRect.bottom, ms->foreColor, false, d->getInkDrawPixel(), this);
+ primitives->drawEllipse(strokeRect.left, strokeRect.top, strokeRect.right, strokeRect.bottom, ms->foreColor, false, this);
break;
case kLineTopBottomSprite:
ms->pd = &plotStroke;
- Graphics::drawLine(strokeRect.left, strokeRect.top, strokeRect.right, strokeRect.bottom, ms->foreColor, d->getInkDrawPixel(), this);
+ primitives->drawLine(strokeRect.left, strokeRect.top, strokeRect.right, strokeRect.bottom, ms->foreColor, this);
break;
case kLineBottomTopSprite:
ms->pd = &plotStroke;
- Graphics::drawLine(strokeRect.left, strokeRect.bottom, strokeRect.right, strokeRect.top, ms->foreColor, d->getInkDrawPixel(), this);
+ primitives->drawLine(strokeRect.left, strokeRect.bottom, strokeRect.right, strokeRect.top, ms->foreColor, this);
break;
default:
warning("DirectorPlotData::inkBlitShape: Expected shape type but got type %d", ms->spriteType);
@@ -710,6 +723,8 @@ void DirectorPlotData::inkBlitSurface(Common::Rect &srcRect, const Graphics::Sur
// format as the window manager. Most of the time this is
// the job of BitmapCastMember::createWidget.
+ Graphics::Primitives *primitives = g_director->getInkPrimitives();
+
srcPoint.y = abs(srcRect.top - destRect.top);
for (int i = 0; i < destRect.height(); i++, srcPoint.y++) {
srcPoint.x = abs(srcRect.left - destRect.left);
@@ -723,10 +738,10 @@ void DirectorPlotData::inkBlitSurface(Common::Rect &srcRect, const Graphics::Sur
if (!mask || (msk && (*msk++))) {
if (d->_wm->_pixelformat.bytesPerPixel == 1) {
- (d->getInkDrawPixel())(destRect.left + j, destRect.top + i,
+ primitives->drawPoint(destRect.left + j, destRect.top + i,
preprocessColor(*((byte *)srf->getBasePtr(srcPoint.x, srcPoint.y))), this);
} else {
- (d->getInkDrawPixel())(destRect.left + j, destRect.top + i,
+ primitives->drawPoint(destRect.left + j, destRect.top + i,
preprocessColor(*((uint32 *)srf->getBasePtr(srcPoint.x, srcPoint.y))), this);
}
}
diff --git a/engines/director/transitions.cpp b/engines/director/transitions.cpp
index b866e1b8a64..85af591d334 100644
--- a/engines/director/transitions.cpp
+++ b/engines/director/transitions.cpp
@@ -1104,6 +1104,8 @@ void Window::transZoom(TransParams &t, Common::Rect &clipRect, Graphics::Managed
pd.destRect = clipRect;
pd.dst = _composeSurface;
+ Graphics::Primitives *primitives = g_director->getInkPrimitives();
+
for (uint16 i = 1; i < t.steps; i++) {
uint32 startTime = g_system->getMillis();
@@ -1124,10 +1126,10 @@ void Window::transZoom(TransParams &t, Common::Rect &clipRect, Graphics::Managed
r.moveTo(t.xStepSize * (i - s), t.yStepSize * (i - s));
}
- Graphics::drawLine(r.left, r.top, r.right, r.top, _wm->_colorBlack, g_director->getInkDrawPixel(), &pd);
- Graphics::drawLine(r.right, r.top, r.right, r.bottom, _wm->_colorBlack, g_director->getInkDrawPixel(), &pd);
- Graphics::drawLine(r.left, r.bottom, r.right, r.bottom, _wm->_colorBlack, g_director->getInkDrawPixel(), &pd);
- Graphics::drawLine(r.left, r.top, r.left, r.bottom, _wm->_colorBlack, g_director->getInkDrawPixel(), &pd);
+ primitives->drawLine(r.left, r.top, r.right, r.top, _wm->_colorBlack, &pd);
+ primitives->drawLine(r.right, r.top, r.right, r.bottom, _wm->_colorBlack, &pd);
+ primitives->drawLine(r.left, r.bottom, r.right, r.bottom, _wm->_colorBlack, &pd);
+ primitives->drawLine(r.left, r.top, r.left, r.bottom, _wm->_colorBlack, &pd);
}
r.setHeight(t.yStepSize * i * 2);
More information about the Scummvm-git-logs
mailing list