浏览代码

Remove screen2 and screenBuf global variables

Ivan Savenko 8 月之前
父节点
当前提交
31e627f128

+ 1 - 3
client/CMT.h

@@ -16,9 +16,7 @@ struct SDL_Surface;
 extern SDL_Texture * screenTexture;
 extern SDL_Renderer * mainRenderer;
 
-extern SDL_Surface *screen;      // main screen surface
-extern SDL_Surface *screen2;     // and hlp surface (used to store not-active interfaces layer)
-extern SDL_Surface *screenBuf; // points to screen (if only advmapint is present) or screen2 (else) - should be used when updating controls which are not regularly redrawed
+extern SDL_Surface *screen;
 
 /// Notify user about encountered fatal error and terminate the game
 /// Defined in clientapp EntryPoint

+ 1 - 4
client/adventureMap/AdventureMapInterface.cpp

@@ -131,8 +131,6 @@ void AdventureMapInterface::activate()
 
 	adjustActiveness();
 
-	screenBuf = screen;
-	
 	if(LOCPLINT)
 	{
 		LOCPLINT->cingconsole->activate();
@@ -453,8 +451,7 @@ void AdventureMapInterface::onPlayerTurnStarted(PlayerColor playerID)
 		widget->getInfoBar()->showDate();
 
 	onHeroChanged(nullptr);
-	Canvas canvas = Canvas::createFromSurface(screen, CanvasScalingPolicy::AUTO);
-	showAll(canvas);
+	GH.windows().totalRedraw();
 	mapAudio->onPlayerTurnStarted();
 
 	if(settings["session"]["autoSkip"].Bool() && !GH.isKeyboardShiftDown())

+ 1 - 8
client/gui/CIntObject.cpp

@@ -238,15 +238,8 @@ void CIntObject::redraw()
 		}
 		else
 		{
-			Canvas buffer = Canvas::createFromSurface(screenBuf, CanvasScalingPolicy::AUTO);
-
+			Canvas buffer = Canvas::createFromSurface(screen, CanvasScalingPolicy::AUTO);
 			showAll(buffer);
-			if(screenBuf != screen)
-			{
-				Canvas screenBuffer = Canvas::createFromSurface(screen, CanvasScalingPolicy::AUTO);
-
-				showAll(screenBuffer);
-			}
 		}
 	}
 }

+ 1 - 9
client/gui/WindowHandler.cpp

@@ -42,9 +42,6 @@ void WindowHandler::pushWindow(std::shared_ptr<IShowActivatable> newInt)
 	if (vstd::contains(windowsStack, newInt))
 		throw std::runtime_error("Attempt to add already existing window to stack!");
 
-	//a new interface will be present, we'll need to use buffer surface (unless it's advmapint that will alter screenBuf on activate anyway)
-	screenBuf = screen2;
-
 	if(!windowsStack.empty())
 		windowsStack.back()->deactivate();
 	windowsStack.push_back(newInt);
@@ -111,11 +108,10 @@ void WindowHandler::totalRedrawImpl()
 {
 	logGlobal->debug("totalRedraw requested!");
 
-	Canvas target = Canvas::createFromSurface(screen2, CanvasScalingPolicy::AUTO);
+	Canvas target = Canvas::createFromSurface(screen, CanvasScalingPolicy::AUTO);
 
 	for(auto & elem : windowsStack)
 		elem->showAll(target);
-	CSDL_Ext::blitAt(screen2, 0, 0, screen);
 }
 
 void WindowHandler::simpleRedraw()
@@ -130,10 +126,6 @@ void WindowHandler::simpleRedraw()
 
 void WindowHandler::simpleRedrawImpl()
 {
-	//update only top interface and draw background
-	if(windowsStack.size() > 1)
-		CSDL_Ext::blitAt(screen2, 0, 0, screen); //blit background
-
 	Canvas target = Canvas::createFromSurface(screen, CanvasScalingPolicy::AUTO);
 
 	if(!windowsStack.empty())

+ 0 - 23
client/renderSDL/ScreenHandler.cpp

@@ -35,8 +35,6 @@ static SDL_Window * mainWindow = nullptr;
 SDL_Renderer * mainRenderer = nullptr;
 SDL_Texture * screenTexture = nullptr;
 SDL_Surface * screen = nullptr; //main screen surface
-SDL_Surface * screen2 = nullptr; //and hlp surface (used to store not-active interfaces layer)
-SDL_Surface * screenBuf = screen; //points to screen (if only advmapint is present) or screen2 (else) - should be used when updating controls which are not regularly redrawed
 
 static const std::string NAME = GameConstants::VCMI_VERSION; //application name
 static constexpr Point heroes3Resolution = Point(800, 600);
@@ -434,18 +432,6 @@ void ScreenHandler::initializeScreenBuffers()
 		throw std::runtime_error("Unable to create screen texture");
 	}
 
-	screen2 = CSDL_Ext::copySurface(screen);
-
-	if(nullptr == screen2)
-	{
-		throw std::runtime_error("Unable to copy surface\n");
-	}
-
-	if (GH.windows().count() > 1)
-		screenBuf = screen2;
-	else
-		screenBuf = screen;
-
 	clearScreen();
 }
 
@@ -590,15 +576,6 @@ int ScreenHandler::getPreferredRenderingDriver() const
 
 void ScreenHandler::destroyScreenBuffers()
 {
-	// screenBuf is not a separate surface, but points to either screen or screen2 - just set to null
-	screenBuf = nullptr;
-
-	if(nullptr != screen2)
-	{
-		SDL_FreeSurface(screen2);
-		screen2 = nullptr;
-	}
-
 	if(nullptr != screen)
 	{
 		SDL_FreeSurface(screen);