[Scummvm-git-logs] scummvm master -> e3ff9b5f9e1a5c204817f2148bc56ca168f7aa4b

aquadran noreply at scummvm.org
Thu Dec 9 21:01:49 UTC 2021


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:
06e79f2adf TINYGL: Use the existing list of rectangles when copying to the screen
e3ff9b5f9e PLAYGROUND3D: Use the existing list of rectangles when copying to the screen


Commit: 06e79f2adf58d40e1a6bce6fa9cba24fbf912ca8
    https://github.com/scummvm/scummvm/commit/06e79f2adf58d40e1a6bce6fa9cba24fbf912ca8
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2021-12-09T22:01:46+01:00

Commit Message:
TINYGL: Use the existing list of rectangles when copying to the screen

Changed paths:
    engines/grim/gfx_tinygl.cpp
    engines/myst3/gfx_tinygl.cpp
    engines/stark/gfx/tinygl.cpp
    graphics/tinygl/tinygl.h
    graphics/tinygl/zdirtyrect.cpp
    graphics/tinygl/zgl.h


diff --git a/engines/grim/gfx_tinygl.cpp b/engines/grim/gfx_tinygl.cpp
index 61a5c758f3..3987e9f2c8 100644
--- a/engines/grim/gfx_tinygl.cpp
+++ b/engines/grim/gfx_tinygl.cpp
@@ -169,10 +169,19 @@ void GfxTinyGL::clearDepthBuffer() {
 }
 
 void GfxTinyGL::flipBuffer() {
-	TinyGL::presentBuffer();
+	Common::List<Common::Rect> dirtyAreas;
+	TinyGL::presentBuffer(dirtyAreas);
+
 	Graphics::Surface glBuffer;
 	TinyGL::getSurfaceRef(glBuffer);
-	g_system->copyRectToScreen(glBuffer.getPixels(), glBuffer.pitch, 0, 0, glBuffer.w, glBuffer.h);
+
+	if (!dirtyAreas.empty()) {
+		for (Common::List<Common::Rect>::iterator itRect = dirtyAreas.begin(); itRect != dirtyAreas.end(); ++itRect) {
+			g_system->copyRectToScreen(glBuffer.getBasePtr((*itRect).left, (*itRect).top), glBuffer.pitch,
+			                           (*itRect).left, (*itRect).top, (*itRect).width(), (*itRect).height());
+		}
+	}
+
 	g_system->updateScreen();
 }
 
diff --git a/engines/myst3/gfx_tinygl.cpp b/engines/myst3/gfx_tinygl.cpp
index 0cba042349..bd331229af 100644
--- a/engines/myst3/gfx_tinygl.cpp
+++ b/engines/myst3/gfx_tinygl.cpp
@@ -272,10 +272,18 @@ Graphics::Surface *TinyGLRenderer::getScreenshot() {
 }
 
 void TinyGLRenderer::flipBuffer() {
-	TinyGL::presentBuffer();
+	Common::List<Common::Rect> dirtyAreas;
+	TinyGL::presentBuffer(dirtyAreas);
+
 	Graphics::Surface glBuffer;
 	TinyGL::getSurfaceRef(glBuffer);
-	g_system->copyRectToScreen(glBuffer.getPixels(), glBuffer.pitch, 0, 0, glBuffer.w, glBuffer.h);
+
+	if (!dirtyAreas.empty()) {
+		for (Common::List<Common::Rect>::iterator itRect = dirtyAreas.begin(); itRect != dirtyAreas.end(); ++itRect) {
+			g_system->copyRectToScreen(glBuffer.getBasePtr((*itRect).left, (*itRect).top), glBuffer.pitch,
+			                           (*itRect).left, (*itRect).top, (*itRect).width(), (*itRect).height());
+		}
+	}
 }
 
 } // End of namespace Myst3
diff --git a/engines/stark/gfx/tinygl.cpp b/engines/stark/gfx/tinygl.cpp
index d854a5d3dd..39f3bd9a68 100644
--- a/engines/stark/gfx/tinygl.cpp
+++ b/engines/stark/gfx/tinygl.cpp
@@ -93,10 +93,19 @@ void TinyGLDriver::clearScreen() {
 }
 
 void TinyGLDriver::flipBuffer() {
-	TinyGL::presentBuffer();
+	Common::List<Common::Rect> dirtyAreas;
+	TinyGL::presentBuffer(dirtyAreas);
+
 	Graphics::Surface glBuffer;
 	TinyGL::getSurfaceRef(glBuffer);
-	g_system->copyRectToScreen(glBuffer.getPixels(), glBuffer.pitch, 0, 0, glBuffer.w, glBuffer.h);
+
+	if (!dirtyAreas.empty()) {
+		for (Common::List<Common::Rect>::iterator itRect = dirtyAreas.begin(); itRect != dirtyAreas.end(); ++itRect) {
+			g_system->copyRectToScreen(glBuffer.getBasePtr((*itRect).left, (*itRect).top), glBuffer.pitch,
+			                           (*itRect).left, (*itRect).top, (*itRect).width(), (*itRect).height());
+		}
+	}
+
 	g_system->updateScreen();
 }
 
diff --git a/graphics/tinygl/tinygl.h b/graphics/tinygl/tinygl.h
index c22010fd7a..c66fd66295 100644
--- a/graphics/tinygl/tinygl.h
+++ b/graphics/tinygl/tinygl.h
@@ -33,6 +33,7 @@ namespace TinyGL {
 void createContext(int screenW, int screenH, Graphics::PixelFormat pixelFormat, int textureSize, bool enableStencilBuffer, bool dirtyRectsEnable = true);
 void destroyContext();
 void presentBuffer();
+void presentBuffer(Common::List<Common::Rect> &dirtyAreas);
 void getSurfaceRef(Graphics::Surface &surface);
 Graphics::Surface *copyToBuffer(const Graphics::PixelFormat &dstFormat);
 
diff --git a/graphics/tinygl/zdirtyrect.cpp b/graphics/tinygl/zdirtyrect.cpp
index 7bf80e9d2c..8a06c51a41 100644
--- a/graphics/tinygl/zdirtyrect.cpp
+++ b/graphics/tinygl/zdirtyrect.cpp
@@ -111,7 +111,7 @@ static inline void _appendDirtyRectangle(const DrawCall &call, Common::List<Dirt
 		rectangles.push_back(DirtyRectangle(dirty_region, r, g, b));
 }
 
-void GLContext::presentBufferDirtyRects() {
+void GLContext::presentBufferDirtyRects(Common::List<Common::Rect> &dirtyAreas) {
 	typedef Common::List<DrawCall *>::const_iterator DrawCallIterator;
 	typedef Common::List<DirtyRectangle>::iterator RectangleIterator;
 
@@ -186,6 +186,10 @@ void GLContext::presentBufferDirtyRects() {
 	}
 
 	if (!rectangles.empty()) {
+		for (RectangleIterator itRect = rectangles.begin(); itRect != rectangles.end(); ++itRect) {
+			dirtyAreas.push_back((*itRect).rectangle);
+		}
+
 		// Execute draw calls.
 		for (DrawCallIterator it = _drawCallsQueue.begin(); it != _drawCallsQueue.end(); ++it) {
 			Common::Rect drawCallRegion = (*it)->getDirtyRegion();
@@ -229,9 +233,11 @@ void GLContext::presentBufferDirtyRects() {
 	_drawCallAllocator[_currentAllocatorIndex].reset();
 }
 
-void GLContext::presentBufferSimple() {
+void GLContext::presentBufferSimple(Common::List<Common::Rect> &dirtyAreas) {
 	typedef Common::List<DrawCall *>::const_iterator DrawCallIterator;
 
+	dirtyAreas.push_back(Common::Rect(fb->getPixelBufferWidth(), fb->getPixelBufferHeight()));
+
 	for (DrawCallIterator it = _drawCallsQueue.begin(); it != _drawCallsQueue.end(); ++it) {
 		(*it)->execute(true);
 		delete *it;
@@ -244,15 +250,20 @@ void GLContext::presentBufferSimple() {
 	_drawCallAllocator[_currentAllocatorIndex].reset();
 }
 
-void presentBuffer() {
+void presentBuffer(Common::List<Common::Rect> &dirtyAreas) {
 	GLContext *c = gl_get_context();
 	if (c->_enableDirtyRectangles) {
-		c->presentBufferDirtyRects();
+		c->presentBufferDirtyRects(dirtyAreas);
 	} else {
-		c->presentBufferSimple();
+		c->presentBufferSimple(dirtyAreas);
 	}
 }
 
+void presentBuffer() {
+	Common::List<Common::Rect> dirtyAreas;
+	presentBuffer(dirtyAreas);
+}
+
 bool DrawCall::operator==(const DrawCall &other) const {
 	if (_type == other._type) {
 		switch (_type) {
diff --git a/graphics/tinygl/zgl.h b/graphics/tinygl/zgl.h
index d1f6295d9f..db17eae9b1 100644
--- a/graphics/tinygl/zgl.h
+++ b/graphics/tinygl/zgl.h
@@ -481,8 +481,8 @@ public:
 	void disposeResources();
 	void disposeDrawCallLists();
 
-	void presentBufferDirtyRects();
-	void presentBufferSimple();
+	void presentBufferDirtyRects(Common::List<Common::Rect> &dirtyAreas);
+	void presentBufferSimple(Common::List<Common::Rect> &dirtyAreas);
 	
 	GLSpecBuf *specbuf_get_buffer(const int shininess_i, const float shininess);
 	void specbuf_cleanup();


Commit: e3ff9b5f9e1a5c204817f2148bc56ca168f7aa4b
    https://github.com/scummvm/scummvm/commit/e3ff9b5f9e1a5c204817f2148bc56ca168f7aa4b
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2021-12-09T22:01:46+01:00

Commit Message:
PLAYGROUND3D: Use the existing list of rectangles when copying to the screen

Changed paths:
    engines/playground3d/gfx_tinygl.cpp


diff --git a/engines/playground3d/gfx_tinygl.cpp b/engines/playground3d/gfx_tinygl.cpp
index 42ae820f64..d94854e13d 100644
--- a/engines/playground3d/gfx_tinygl.cpp
+++ b/engines/playground3d/gfx_tinygl.cpp
@@ -229,10 +229,18 @@ void TinyGLRenderer::drawPolyOffsetTest(const Math::Vector3d &pos, const Math::V
 }
 
 void TinyGLRenderer::flipBuffer() {
-	TinyGL::presentBuffer();
+	Common::List<Common::Rect> dirtyAreas;
+	TinyGL::presentBuffer(dirtyAreas);
+
 	Graphics::Surface glBuffer;
 	TinyGL::getSurfaceRef(glBuffer);
-	g_system->copyRectToScreen(glBuffer.getPixels(), glBuffer.pitch, 0, 0, glBuffer.w, glBuffer.h);
+
+	if (!dirtyAreas.empty()) {
+		for (Common::List<Common::Rect>::iterator itRect = dirtyAreas.begin(); itRect != dirtyAreas.end(); ++itRect) {
+			g_system->copyRectToScreen(glBuffer.getBasePtr((*itRect).left, (*itRect).top), glBuffer.pitch,
+			                           (*itRect).left, (*itRect).top, (*itRect).width(), (*itRect).height());
+		}
+	}
 }
 
 void TinyGLRenderer::dimRegionInOut(float fade) {




More information about the Scummvm-git-logs mailing list