Changeset - r25013:4c02a1340d93
[Not reviewed]
master
0 2 0
Michael Lutz - 3 years ago 2021-03-08 12:48:32
michi@icosahedron.de
Codechange: don't set the window position when changing blitter

There really is no need to make an extra call to the OS in
these cases.
2 files changed with 6 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/video/win32_v.cpp
Show inline comments
 
@@ -125,15 +125,16 @@ uint8 VideoDriver_Win32Base::GetFullscre
 
	return _support8bpp != S8BPP_HARDWARE ? 32 : BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
 
}
 

	
 
/**
 
 * Instantiate a new window.
 
 * @param full_screen Whether to make a full screen window or not.
 
 * @param resize Whether to change window size.
 
 * @return True if the window could be created.
 
 */
 
bool VideoDriver_Win32Base::MakeWindow(bool full_screen)
 
bool VideoDriver_Win32Base::MakeWindow(bool full_screen, bool resize)
 
{
 
	/* full_screen is whether the new window should be fullscreen,
 
	 * _wnd.fullscreen is whether the current window is. */
 
	_fullscreen = full_screen;
 

	
 
	/* recreate window? */
 
@@ -169,13 +170,13 @@ bool VideoDriver_Win32Base::MakeWindow(b
 
			if ((int)settings.dmPelsWidth != r.right - r.left || (int)settings.dmPelsHeight != r.bottom - r.top) {
 
				return this->ChangeResolution(r.right - r.left, r.bottom - r.top);
 
			}
 
		}
 

	
 
		if (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) {
 
			this->MakeWindow(false);  // don't care about the result
 
			this->MakeWindow(false, resize);  // don't care about the result
 
			return false;  // the request failed
 
		}
 
	} else if (this->fullscreen) {
 
		/* restore display? */
 
		ChangeDisplaySettings(nullptr, 0);
 
		/* restore the resolution */
 
@@ -202,13 +203,13 @@ bool VideoDriver_Win32Base::MakeWindow(b
 

	
 
		AdjustWindowRect(&r, style, FALSE);
 
		w = r.right - r.left;
 
		h = r.bottom - r.top;
 

	
 
		if (this->main_wnd != nullptr) {
 
			if (!_window_maximize) SetWindowPos(this->main_wnd, 0, 0, 0, w, h, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
 
			if (!_window_maximize && resize) SetWindowPos(this->main_wnd, 0, 0, 0, w, h, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
 
		} else {
 
			int x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
 
			int y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2;
 

	
 
			char window_title[64];
 
			seprintf(window_title, lastof(window_title), "OpenTTD %s", _openttd_revision);
 
@@ -1040,13 +1041,13 @@ bool VideoDriver_Win32GDI::AllocateBacki
 
	return true;
 
}
 

	
 
bool VideoDriver_Win32GDI::AfterBlitterChange()
 
{
 
	assert(BlitterFactory::GetCurrentBlitter()->GetScreenDepth() != 0);
 
	return this->AllocateBackingStore(_screen.width, _screen.height, true) && this->MakeWindow(_fullscreen);
 
	return this->AllocateBackingStore(_screen.width, _screen.height, true) && this->MakeWindow(_fullscreen, false);
 
}
 

	
 
void VideoDriver_Win32GDI::MakePalette()
 
{
 
	_cur_palette.first_dirty = 0;
 
	_cur_palette.count_dirty = 256;
src/video/win32_v.h
Show inline comments
 
@@ -51,13 +51,13 @@ protected:
 
	bool LockVideoBuffer() override;
 
	void UnlockVideoBuffer() override;
 
	void CheckPaletteAnim() override;
 
	bool PollEvent() override;
 

	
 
	void Initialize();
 
	bool MakeWindow(bool full_screen);
 
	bool MakeWindow(bool full_screen, bool resize = true);
 
	void ClientSizeChanged(int w, int h, bool force = false);
 

	
 
	/** Get screen depth to use for fullscreen mode. */
 
	virtual uint8 GetFullscreenBpp();
 
	/** (Re-)create the backing store. */
 
	virtual bool AllocateBackingStore(int w, int h, bool force = false) = 0;
0 comments (0 inline, 0 general)