Skip to content

Commit 1fc1122

Browse files
committed
Consolidate test window creation code
1 parent 94d47e9 commit 1fc1122

File tree

4 files changed

+35
-28
lines changed

4 files changed

+35
-28
lines changed

app/backend/systemproperties.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -184,21 +184,13 @@ void SystemProperties::startAsyncLoad()
184184
return;
185185
}
186186

187-
testWindow = SDL_CreateWindow("", 0, 0, 1280, 720,
188-
SDL_WINDOW_HIDDEN | StreamUtils::getPlatformWindowFlags());
187+
testWindow = StreamUtils::createTestWindow();
189188
if (!testWindow) {
190-
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
191-
"Failed to create test window with platform flags: %s",
192-
SDL_GetError());
193-
194-
testWindow = SDL_CreateWindow("", 0, 0, 1280, 720, SDL_WINDOW_HIDDEN);
195-
if (!testWindow) {
196-
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
197-
"Failed to create window for hardware decode test: %s",
198-
SDL_GetError());
199-
SDL_QuitSubSystem(SDL_INIT_VIDEO);
200-
return;
201-
}
189+
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
190+
"Failed to create window for hardware decode test: %s",
191+
SDL_GetError());
192+
SDL_QuitSubSystem(SDL_INIT_VIDEO);
193+
return;
202194
}
203195

204196
// Update display related attributes (max FPS, native resolution, etc).

app/streaming/session.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -640,21 +640,13 @@ bool Session::initialize(QQuickWindow* qtWindow)
640640
getWindowDimensions(x, y, width, height);
641641

642642
// Create a hidden window to use for decoder initialization tests
643-
SDL_Window* testWindow = SDL_CreateWindow("", x, y, width, height,
644-
SDL_WINDOW_HIDDEN | StreamUtils::getPlatformWindowFlags());
643+
SDL_Window* testWindow = StreamUtils::createTestWindow();
645644
if (!testWindow) {
646-
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
647-
"Failed to create test window with platform flags: %s",
648-
SDL_GetError());
649-
650-
testWindow = SDL_CreateWindow("", x, y, width, height, SDL_WINDOW_HIDDEN);
651-
if (!testWindow) {
652-
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
653-
"Failed to create window for hardware decode test: %s",
654-
SDL_GetError());
655-
SDL_QuitSubSystem(SDL_INIT_VIDEO);
656-
return false;
657-
}
645+
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
646+
"Failed to create window for hardware decode test: %s",
647+
SDL_GetError());
648+
SDL_QuitSubSystem(SDL_INIT_VIDEO);
649+
return false;
658650
}
659651

660652
qInfo() << "Server GPU:" << m_Computer->gpuModel;

app/streaming/streamutils.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,26 @@ Uint32 StreamUtils::getPlatformWindowFlags()
8484
#endif
8585
}
8686

87+
SDL_Window* StreamUtils::createTestWindow()
88+
{
89+
SDL_Window* testWindow;
90+
91+
testWindow = SDL_CreateWindow("", 0, 0, 1280, 720,
92+
SDL_WINDOW_HIDDEN | StreamUtils::getPlatformWindowFlags());
93+
if (!testWindow) {
94+
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
95+
"Failed to create test window with platform flags: %s",
96+
SDL_GetError());
97+
98+
testWindow = SDL_CreateWindow("", 0, 0, 1280, 720, SDL_WINDOW_HIDDEN);
99+
if (!testWindow) {
100+
return nullptr;
101+
}
102+
}
103+
104+
return testWindow;
105+
}
106+
87107
void StreamUtils::scaleSourceToDestinationSurface(SDL_Rect* src, SDL_Rect* dst)
88108
{
89109
int dstH = SDL_ceilf((float)dst->w * src->h / src->w);

app/streaming/streamutils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ class StreamUtils
88
static
99
Uint32 getPlatformWindowFlags();
1010

11+
static
12+
SDL_Window* createTestWindow();
13+
1114
static
1215
void scaleSourceToDestinationSurface(SDL_Rect* src, SDL_Rect* dst);
1316

0 commit comments

Comments
 (0)