[Scummvm-git-logs] scummvm master -> d8cca29783e6f6259bb26efa8c2ba8c077e1037a
sev-
noreply at scummvm.org
Sun Aug 6 21:03:50 UTC 2023
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:
d8cca29783 BACKENDS: Allow filling part of the screen with OSystem::fillScreen
Commit: d8cca29783e6f6259bb26efa8c2ba8c077e1037a
https://github.com/scummvm/scummvm/commit/d8cca29783e6f6259bb26efa8c2ba8c077e1037a
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-08-06T23:03:46+02:00
Commit Message:
BACKENDS: Allow filling part of the screen with OSystem::fillScreen
Changed paths:
backends/base-backend.cpp
backends/base-backend.h
backends/graphics/atari/atari-graphics.cpp
backends/graphics/atari/atari-graphics.h
backends/graphics/graphics.h
backends/graphics/null/null-graphics.h
backends/graphics/opengl/opengl-graphics.cpp
backends/graphics/opengl/opengl-graphics.h
backends/graphics/opengl/texture.cpp
backends/graphics/opengl/texture.h
backends/graphics/surfacesdl/surfacesdl-graphics.cpp
backends/graphics/surfacesdl/surfacesdl-graphics.h
backends/graphics3d/android/android-graphics3d.cpp
backends/graphics3d/android/android-graphics3d.h
backends/graphics3d/ios/ios-graphics3d.h
backends/graphics3d/openglsdl/openglsdl-graphics3d.h
backends/modular-backend.cpp
backends/modular-backend.h
common/system.h
engines/asylum/system/screen.cpp
test/null_osystem.cpp
diff --git a/backends/base-backend.cpp b/backends/base-backend.cpp
index b20b2815805..dcd7337bca8 100644
--- a/backends/base-backend.cpp
+++ b/backends/base-backend.cpp
@@ -75,6 +75,13 @@ void BaseBackend::fillScreen(uint32 col) {
unlockScreen();
}
+void BaseBackend::fillScreen(const Common::Rect &r, uint32 col) {
+ Graphics::Surface *screen = lockScreen();
+ if (screen)
+ screen->fillRect(r, col);
+ unlockScreen();
+}
+
void EventsBaseBackend::initBackend() {
// Init Event manager
#ifndef DISABLE_DEFAULT_EVENT_MANAGER
diff --git a/backends/base-backend.h b/backends/base-backend.h
index b566e498cee..36cab351686 100644
--- a/backends/base-backend.h
+++ b/backends/base-backend.h
@@ -38,6 +38,7 @@ public:
void displayMessageOnOSD(const Common::U32String &msg) override;
void displayActivityIconOnOSD(const Graphics::Surface *icon) override {}
void fillScreen(uint32 col) override;
+ void fillScreen(const Common::Rect &r, uint32 col) override;
};
class EventsBaseBackend : virtual public BaseBackend, Common::EventSource {
diff --git a/backends/graphics/atari/atari-graphics.cpp b/backends/graphics/atari/atari-graphics.cpp
index 14722fc7d7b..54e583b19c2 100644
--- a/backends/graphics/atari/atari-graphics.cpp
+++ b/backends/graphics/atari/atari-graphics.cpp
@@ -453,6 +453,13 @@ void AtariGraphicsManager::fillScreen(uint32 col) {
unlockScreen();
}
+void AtariGraphicsManager::fillScreen(const Common::Rect &r, uint32 col) {
+ Graphics::Surface *screen = lockScreen();
+ if (screen)
+ screen->fillRect(r, col);
+ unlockScreen();
+}
+
void AtariGraphicsManager::updateScreen() {
//debug("updateScreen");
diff --git a/backends/graphics/atari/atari-graphics.h b/backends/graphics/atari/atari-graphics.h
index 5f9d56d8783..8010087c144 100644
--- a/backends/graphics/atari/atari-graphics.h
+++ b/backends/graphics/atari/atari-graphics.h
@@ -71,6 +71,7 @@ public:
Graphics::Surface *lockScreen() override;
void unlockScreen() override;
void fillScreen(uint32 col) override;
+ void fillScreen(const Common::Rect &r, uint32 col) override;
void updateScreen() override;
void setShakePos(int shakeXOffset, int shakeYOffset) override;
void setFocusRectangle(const Common::Rect& rect) override {}
diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h
index 553bc26effc..d68a1ef3e38 100644
--- a/backends/graphics/graphics.h
+++ b/backends/graphics/graphics.h
@@ -81,6 +81,7 @@ public:
virtual Graphics::Surface *lockScreen() = 0;
virtual void unlockScreen() = 0;
virtual void fillScreen(uint32 col) = 0;
+ virtual void fillScreen(const Common::Rect &r, uint32 col) = 0;
virtual void updateScreen() = 0;
virtual void setShakePos(int shakeXOffset, int shakeYOffset) = 0;
virtual void setFocusRectangle(const Common::Rect& rect) = 0;
diff --git a/backends/graphics/null/null-graphics.h b/backends/graphics/null/null-graphics.h
index 885b0c99266..93115784bcd 100644
--- a/backends/graphics/null/null-graphics.h
+++ b/backends/graphics/null/null-graphics.h
@@ -68,6 +68,7 @@ public:
Graphics::Surface *lockScreen() override { return NULL; }
void unlockScreen() override {}
void fillScreen(uint32 col) override {}
+ void fillScreen(const Common::Rect &r, uint32 col) override {}
void updateScreen() override {}
void setShakePos(int shakeXOffset, int shakeYOffset) override {}
void setFocusRectangle(const Common::Rect& rect) override {}
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index b537522ace6..5fa991e78d8 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -592,6 +592,10 @@ void OpenGLGraphicsManager::fillScreen(uint32 col) {
_gameScreen->fill(col);
}
+void OpenGLGraphicsManager::fillScreen(const Common::Rect &r, uint32 col) {
+ _gameScreen->fill(r, col);
+}
+
void OpenGLGraphicsManager::renderCursor() {
/*
Windows and Mac cursor XOR works by drawing the cursor to the screen with the formula (Destination AND Mask XOR Color)
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index 5532559da37..cdedb1d0d81 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -101,6 +101,7 @@ public:
void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) override;
void fillScreen(uint32 col) override;
+ void fillScreen(const Common::Rect &r, uint32 col) override;
void updateScreen() override;
diff --git a/backends/graphics/opengl/texture.cpp b/backends/graphics/opengl/texture.cpp
index 67b9ae93c5e..4fdc19ef049 100644
--- a/backends/graphics/opengl/texture.cpp
+++ b/backends/graphics/opengl/texture.cpp
@@ -234,15 +234,7 @@ void Surface::copyRectToTexture(uint x, uint y, uint w, uint h, const void *srcP
assert(x + w <= (uint)dstSurf->w);
assert(y + h <= (uint)dstSurf->h);
- // *sigh* Common::Rect::extend behaves unexpected whenever one of the two
- // parameters is an empty rect. Thus, we check whether the current dirty
- // area is valid. In case it is not we simply use the parameters as new
- // dirty area. Otherwise, we simply call extend.
- if (_dirtyArea.isEmpty()) {
- _dirtyArea = Common::Rect(x, y, x + w, y + h);
- } else {
- _dirtyArea.extend(Common::Rect(x, y, x + w, y + h));
- }
+ addDirtyArea(Common::Rect(x, y, x + w, y + h));
const byte *src = (const byte *)srcPtr;
byte *dst = (byte *)dstSurf->getBasePtr(x, y);
@@ -267,6 +259,25 @@ void Surface::fill(uint32 color) {
flagDirty();
}
+void Surface::fill(const Common::Rect &r, uint32 color) {
+ Graphics::Surface *dst = getSurface();
+ dst->fillRect(r, color);
+
+ addDirtyArea(r);
+}
+
+void Surface::addDirtyArea(const Common::Rect &r) {
+ // *sigh* Common::Rect::extend behaves unexpected whenever one of the two
+ // parameters is an empty rect. Thus, we check whether the current dirty
+ // area is valid. In case it is not we simply use the parameters as new
+ // dirty area. Otherwise, we simply call extend.
+ if (_dirtyArea.isEmpty()) {
+ _dirtyArea = r;
+ } else {
+ _dirtyArea.extend(r);
+ }
+}
+
Common::Rect Surface::getDirtyArea() const {
if (_allDirty) {
return Common::Rect(getWidth(), getHeight());
diff --git a/backends/graphics/opengl/texture.h b/backends/graphics/opengl/texture.h
index 25b611c613b..ab251f3e318 100644
--- a/backends/graphics/opengl/texture.h
+++ b/backends/graphics/opengl/texture.h
@@ -221,6 +221,7 @@ public:
* @param color Color value in format returned by getFormat.
*/
void fill(uint32 color);
+ void fill(const Common::Rect &r, uint32 color);
void flagDirty() { _allDirty = true; }
virtual bool isDirty() const { return _allDirty || !_dirtyArea.isEmpty(); }
@@ -265,6 +266,7 @@ public:
protected:
void clearDirty() { _allDirty = false; _dirtyArea = Common::Rect(); }
+ void addDirtyArea(const Common::Rect &r);
Common::Rect getDirtyArea() const;
private:
bool _allDirty;
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 919df8be5f2..9ee0d0ec580 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -1685,6 +1685,13 @@ void SurfaceSdlGraphicsManager::fillScreen(uint32 col) {
unlockScreen();
}
+void SurfaceSdlGraphicsManager::fillScreen(const Common::Rect &r, uint32 col) {
+ Graphics::Surface *screen = lockScreen();
+ if (screen)
+ screen->fillRect(r, col);
+ unlockScreen();
+}
+
void SurfaceSdlGraphicsManager::addDirtyRect(int x, int y, int w, int h, bool inOverlay, bool realCoordinates) {
if (_forceRedraw)
return;
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h
index 8078c8eb089..02e5c61748b 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.h
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h
@@ -113,6 +113,7 @@ public:
Graphics::Surface *lockScreen() override;
void unlockScreen() override;
void fillScreen(uint32 col) override;
+ void fillScreen(const Common::Rect &r, uint32 col) override;
void updateScreen() override;
void setFocusRectangle(const Common::Rect& rect) override;
void clearFocusRectangle() override;
diff --git a/backends/graphics3d/android/android-graphics3d.cpp b/backends/graphics3d/android/android-graphics3d.cpp
index 0484352fdc5..d4a95f79fa5 100644
--- a/backends/graphics3d/android/android-graphics3d.cpp
+++ b/backends/graphics3d/android/android-graphics3d.cpp
@@ -706,6 +706,11 @@ void AndroidGraphics3dManager::fillScreen(uint32 col) {
assert(false);
}
+void AndroidGraphics3dManager::fillScreen(const Common::Rect &r, uint32 col) {
+ // We should never end up here in 3D
+ assert(false);
+}
+
void AndroidGraphics3dManager::copyRectToScreen(const void *buf, int pitch,
int x, int y, int w, int h) {
// We should never end up here in 3D
diff --git a/backends/graphics3d/android/android-graphics3d.h b/backends/graphics3d/android/android-graphics3d.h
index 13fe33a023d..6f4f3f23d5a 100644
--- a/backends/graphics3d/android/android-graphics3d.h
+++ b/backends/graphics3d/android/android-graphics3d.h
@@ -94,7 +94,8 @@ public:
int w, int h) override;
virtual Graphics::Surface *lockScreen() override;
virtual void unlockScreen() override;
- virtual void fillScreen(uint32 col);
+ virtual void fillScreen(uint32 col) override;
+ virtial void fillScreen(const Common::Rect &r, uint32 col) override;
virtual void setShakePos(int shakeXOffset, int shakeYOffset) {};
virtual void setFocusRectangle(const Common::Rect &rect) {}
diff --git a/backends/graphics3d/ios/ios-graphics3d.h b/backends/graphics3d/ios/ios-graphics3d.h
index 2b323bbe034..a6923f1aa38 100644
--- a/backends/graphics3d/ios/ios-graphics3d.h
+++ b/backends/graphics3d/ios/ios-graphics3d.h
@@ -93,6 +93,7 @@ public:
Graphics::Surface *lockScreen() override { return nullptr; }
void unlockScreen() override {}
void fillScreen(uint32 col) override {}
+ void fillScreen(const Common::Rect &r, uint32 col) override {}
void setShakePos(int shakeXOffset, int shakeYOffset) override {};
void setFocusRectangle(const Common::Rect& rect) override {}
void clearFocusRectangle() override {}
diff --git a/backends/graphics3d/openglsdl/openglsdl-graphics3d.h b/backends/graphics3d/openglsdl/openglsdl-graphics3d.h
index 2100d2620f1..6fc94e5d9ea 100644
--- a/backends/graphics3d/openglsdl/openglsdl-graphics3d.h
+++ b/backends/graphics3d/openglsdl/openglsdl-graphics3d.h
@@ -87,6 +87,7 @@ public:
Graphics::Surface *lockScreen() override { return nullptr; }
void unlockScreen() override {}
void fillScreen(uint32 col) override {}
+ void fillScreen(const Common::Rect &r, uint32 col) override {}
void setShakePos(int shakeXOffset, int shakeYOffset) override {};
void setFocusRectangle(const Common::Rect& rect) override {}
void clearFocusRectangle() override {}
diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp
index dfab11a165c..e5b85c1485b 100644
--- a/backends/modular-backend.cpp
+++ b/backends/modular-backend.cpp
@@ -173,6 +173,10 @@ void ModularGraphicsBackend::fillScreen(uint32 col) {
_graphicsManager->fillScreen(col);
}
+void ModularGraphicsBackend::fillScreen(const Common::Rect &r, uint32 col) {
+ _graphicsManager->fillScreen(r, col);
+}
+
void ModularGraphicsBackend::updateScreen() {
#ifdef ENABLE_EVENTRECORDER
g_system->getMillis(); // force event recorder to update the tick count
diff --git a/backends/modular-backend.h b/backends/modular-backend.h
index 71713a81e2e..0c4ebe0f429 100644
--- a/backends/modular-backend.h
+++ b/backends/modular-backend.h
@@ -96,6 +96,7 @@ public:
Graphics::Surface *lockScreen() override final;
void unlockScreen() override final;
void fillScreen(uint32 col) override final;
+ void fillScreen(const Common::Rect &r, uint32 col) override final;
void updateScreen() override final;
void setShakePos(int shakeXOffset, int shakeYOffset) override final;
void setFocusRectangle(const Common::Rect& rect) override final;
diff --git a/common/system.h b/common/system.h
index bec293b637a..d07d26e0356 100644
--- a/common/system.h
+++ b/common/system.h
@@ -1155,6 +1155,11 @@ public:
*/
virtual void fillScreen(uint32 col) = 0;
+ /**
+ * Fill the specified area of the screen with the given color value.
+ */
+ virtual void fillScreen(const Common::Rect &r, uint32 col) = 0;
+
/**
* Flush the whole screen, i.e. render the current content of the screen
* framebuffer to the display.
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 10a44e01e6e..0b1ccb0875e 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -197,10 +197,8 @@ void Screen::clear() {
void Screen::drawWideScreenBars(int16 barSize) const {
if (barSize > 0) {
- _vm->_system->lockScreen()->fillRect(Common::Rect(0, 0, 640, barSize), 0);
- _vm->_system->unlockScreen();
- _vm->_system->lockScreen()->fillRect(Common::Rect(0, 480 - barSize, 640, 480), 0);
- _vm->_system->unlockScreen();
+ _vm->_system->fillScreen(Common::Rect(0, 0, 640, barSize), 0);
+ _vm->_system->fillScreen(Common::Rect(0, 480 - barSize, 640, 480), 0);
}
}
diff --git a/test/null_osystem.cpp b/test/null_osystem.cpp
index 7fd0e0329c9..6f1d0540109 100644
--- a/test/null_osystem.cpp
+++ b/test/null_osystem.cpp
@@ -21,6 +21,9 @@ void BaseBackend::initBackend() {
void BaseBackend::fillScreen(uint32 col) {
}
+void BaseBackend::fillScreen(const Common::Rect &r, uint32 col) {
+}
+
void EventsBaseBackend::initBackend() {
BaseBackend::initBackend();
}
More information about the Scummvm-git-logs
mailing list