Browse Source

Removing resize flicker on MS-Windows, but not the gray flicker when outside of the screen.

David Piuva 2 years ago
parent
commit
e8516c9a61
2 changed files with 7 additions and 1 deletions
  1. 1 1
      Source/DFPSR/gui/BackendWindow.cpp
  2. 6 0
      Source/windowManagers/Win32Window.cpp

+ 1 - 1
Source/DFPSR/gui/BackendWindow.cpp

@@ -64,7 +64,7 @@ bool BackendWindow::executeEvents() {
 				if (wEvent->windowEventType == WindowEventType::Close) {
 				if (wEvent->windowEventType == WindowEventType::Close) {
 					this->callback_closeEvent();
 					this->callback_closeEvent();
 				} else if (wEvent->windowEventType == WindowEventType::Redraw) {
 				} else if (wEvent->windowEventType == WindowEventType::Redraw) {
-					this->showCanvas();
+					//this->showCanvas();
 				}
 				}
 			}
 			}
 		}
 		}

+ 6 - 0
Source/windowManagers/Win32Window.cpp

@@ -569,8 +569,14 @@ void Win32Window::resizeCanvas(int width, int height) {
 	// Create a new canvas
 	// Create a new canvas
 	//   Even thou Windows is using RGBA pack order for the window, the bitmap format used for drawing is using BGRA order
 	//   Even thou Windows is using RGBA pack order for the window, the bitmap format used for drawing is using BGRA order
 	for (int bufferIndex = 0; bufferIndex < bufferCount; bufferIndex++) {
 	for (int bufferIndex = 0; bufferIndex < bufferCount; bufferIndex++) {
+		dsr::AlignedImageRgbaU8 previousCanvas = this->canvas[bufferIndex];
 		this->canvas[bufferIndex] = dsr::image_create_RgbaU8_native(width, height, dsr::PackOrderIndex::BGRA);
 		this->canvas[bufferIndex] = dsr::image_create_RgbaU8_native(width, height, dsr::PackOrderIndex::BGRA);
+		if (image_exists(previousCanvas)) {
+			// Until the application's main loop has redrawn, fill the new canvas with a copy of the old one with black borders.
+			dsr::draw_copy(this->canvas[bufferIndex], previousCanvas);
+		}
 	}
 	}
+	this->firstFrame = true;
 }
 }
 Win32Window::~Win32Window() {
 Win32Window::~Win32Window() {
 	#ifndef DISABLE_MULTI_THREADING
 	#ifndef DISABLE_MULTI_THREADING