summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/framebuffer_layout.cpp86
1 files changed, 36 insertions, 50 deletions
diff --git a/src/common/framebuffer_layout.cpp b/src/common/framebuffer_layout.cpp
index a0e75090d..42cfa32a9 100644
--- a/src/common/framebuffer_layout.cpp
+++ b/src/common/framebuffer_layout.cpp
@@ -201,47 +201,40 @@ static FramebufferLayout LargeFrameLayout(unsigned width, unsigned height) {
201 ASSERT(width > 0); 201 ASSERT(width > 0);
202 ASSERT(height > 0); 202 ASSERT(height > 0);
203 203
204 FramebufferLayout res {width, height, true, true, {}, {}}; 204 FramebufferLayout res{ width, height, true, true,{},{} };
205 205
206 float window_aspect_ratio = static_cast<float>(height) / width; 206 float window_aspect_ratio = static_cast<float>(width) / height;
207 float emulation_aspect_ratio = static_cast<float>(VideoCore::kScreenTopHeight * 4) / 207 float top_screen_aspect_ratio = static_cast<float>(VideoCore::kScreenTopWidth) /
208 (VideoCore::kScreenTopWidth * 4 + VideoCore::kScreenBottomWidth); 208 VideoCore::kScreenTopHeight;
209 209
210 if (window_aspect_ratio > emulation_aspect_ratio) { 210 int viewport_height = static_cast<int>(std::round((width - VideoCore::kScreenBottomWidth) /
211 // Window is narrower than the emulation content => apply borders to the top and bottom 211 top_screen_aspect_ratio));
212 int viewport_height = static_cast<int>(std::round(emulation_aspect_ratio * width)); 212 int viewport_width = static_cast<int>(std::round((height * top_screen_aspect_ratio) +
213 VideoCore::kScreenBottomWidth));
214 float emulation_aspect_ratio = static_cast<float>(width) / viewport_height;
213 215
216 if (window_aspect_ratio < emulation_aspect_ratio) {
217 // Window is narrower than the emulation content => apply borders to the top and bottom
214 res.top_screen.left = 0; 218 res.top_screen.left = 0;
215 // Top screen occupies 4 / 5ths of the total width 219 res.top_screen.right = width - VideoCore::kScreenBottomWidth;
216 res.top_screen.right = static_cast<int>(std::round(width / 5)) * 4;
217 res.top_screen.top = (height - viewport_height) / 2; 220 res.top_screen.top = (height - viewport_height) / 2;
218 res.top_screen.bottom = res.top_screen.top + viewport_height; 221 res.top_screen.bottom = viewport_height + res.top_screen.top;
219
220 int bottom_height = static_cast<int>((static_cast<float>(VideoCore::kScreenBottomHeight) /
221 VideoCore::kScreenBottomWidth) * (width - res.top_screen.right));
222 222
223 res.bottom_screen.left = res.top_screen.right; 223 res.bottom_screen.left = res.top_screen.right;
224 res.bottom_screen.right = width; 224 res.bottom_screen.right = width;
225 res.bottom_screen.bottom = res.top_screen.bottom; 225 res.bottom_screen.bottom = res.top_screen.bottom;
226 res.bottom_screen.top = res.bottom_screen.bottom - bottom_height; 226 res.bottom_screen.top = res.bottom_screen.bottom - VideoCore::kScreenBottomHeight;
227 } else { 227 } else {
228 // Otherwise, apply borders to the left and right sides of the window. 228 // Otherwise, apply borders to the left and right sides of the window.
229 int viewport_width = static_cast<int>(std::round(height / emulation_aspect_ratio));
230 // Break the viewport into fifths and give top 4 of them
231 int fifth_width = static_cast<int>(std::round(viewport_width / 5));
232
233 res.top_screen.left = (width - viewport_width) / 2; 229 res.top_screen.left = (width - viewport_width) / 2;
234 res.top_screen.right = res.top_screen.left + fifth_width * 4; 230 res.top_screen.right = (top_screen_aspect_ratio * height) + res.top_screen.left;
235 res.top_screen.top = 0; 231 res.top_screen.top = 0;
236 res.top_screen.bottom = height; 232 res.top_screen.bottom = height;
237 233
238 int bottom_height = static_cast<int>((static_cast<float>(VideoCore::kScreenBottomHeight) /
239 VideoCore::kScreenBottomWidth) * (fifth_width));
240
241 res.bottom_screen.left = res.top_screen.right; 234 res.bottom_screen.left = res.top_screen.right;
242 res.bottom_screen.right = width - (width - viewport_width) / 2; 235 res.bottom_screen.right = res.bottom_screen.left + VideoCore::kScreenBottomWidth;
243 res.bottom_screen.bottom = res.top_screen.bottom; 236 res.bottom_screen.bottom = height;
244 res.bottom_screen.top = res.bottom_screen.bottom - bottom_height; 237 res.bottom_screen.top = height - VideoCore::kScreenBottomHeight;
245 } 238 }
246 239
247 return res; 240 return res;
@@ -254,45 +247,38 @@ static FramebufferLayout LargeFrameLayout_Swapped(unsigned width, unsigned heigh
254 247
255 FramebufferLayout res {width, height, true, true, {}, {}}; 248 FramebufferLayout res {width, height, true, true, {}, {}};
256 249
257 float window_aspect_ratio = static_cast<float>(height) / width; 250 float window_aspect_ratio = static_cast<float>(width) / height;
258 float emulation_aspect_ratio = static_cast<float>(VideoCore::kScreenBottomHeight * 4) / 251 float bottom_screen_aspect_ratio = static_cast<float>(VideoCore::kScreenBottomWidth) /
259 (VideoCore::kScreenBottomWidth * 4 + VideoCore::kScreenTopWidth); 252 VideoCore::kScreenBottomHeight;
260 253
261 if (window_aspect_ratio > emulation_aspect_ratio) { 254 int viewport_height = static_cast<int>(std::round((width - VideoCore::kScreenTopWidth) /
262 // Window is narrower than the emulation content => apply borders to the top and bottom 255 bottom_screen_aspect_ratio));
263 int viewport_height = static_cast<int>(std::round(emulation_aspect_ratio * width)); 256 int viewport_width = static_cast<int>(std::round((height * bottom_screen_aspect_ratio) +
257 VideoCore::kScreenTopWidth));
258 float emulation_aspect_ratio = static_cast<float>(width) / viewport_height;
264 259
260 if (window_aspect_ratio < emulation_aspect_ratio) {
261 // Window is narrower than the emulation content => apply borders to the top and bottom
265 res.bottom_screen.left = 0; 262 res.bottom_screen.left = 0;
266 // Top screen occupies 4 / 5ths of the total width 263 res.bottom_screen.right = width - VideoCore::kScreenTopWidth;
267 res.bottom_screen.right = static_cast<int>(std::round(width / 5)) * 4;
268 res.bottom_screen.top = (height - viewport_height) / 2; 264 res.bottom_screen.top = (height - viewport_height) / 2;
269 res.bottom_screen.bottom = res.bottom_screen.top + viewport_height; 265 res.bottom_screen.bottom = viewport_height + res.bottom_screen.top;
270
271 int top_height = static_cast<int>((static_cast<float>(VideoCore::kScreenTopHeight) /
272 VideoCore::kScreenTopWidth) * (width - res.bottom_screen.right));
273 266
274 res.top_screen.left = res.bottom_screen.right; 267 res.top_screen.left = res.bottom_screen.right;
275 res.top_screen.right = width; 268 res.top_screen.right = width;
276 res.top_screen.bottom = res.bottom_screen.bottom; 269 res.top_screen.bottom = res.bottom_screen.bottom;
277 res.top_screen.top = res.top_screen.bottom - top_height; 270 res.top_screen.top = res.top_screen.bottom - VideoCore::kScreenTopHeight;
278 } else { 271 } else {
279 // Otherwise, apply borders to the left and right sides of the window. 272 // Otherwise, apply borders to the left and right sides of the window.
280 int viewport_width = static_cast<int>(std::round(height / emulation_aspect_ratio));
281 // Break the viewport into fifths and give top 4 of them
282 int fifth_width = static_cast<int>(std::round(viewport_width / 5));
283
284 res.bottom_screen.left = (width - viewport_width) / 2; 273 res.bottom_screen.left = (width - viewport_width) / 2;
285 res.bottom_screen.right = res.bottom_screen.left + fifth_width * 4; 274 res.bottom_screen.right = (bottom_screen_aspect_ratio * height) + res.bottom_screen.left;
286 res.bottom_screen.top = 0; 275 res.bottom_screen.top = 0;
287 res.bottom_screen.bottom = height; 276 res.bottom_screen.bottom = height;
288 277
289 int top_height = static_cast<int>((static_cast<float>(VideoCore::kScreenTopHeight) /
290 VideoCore::kScreenTopWidth) * (fifth_width));
291
292 res.top_screen.left = res.bottom_screen.right; 278 res.top_screen.left = res.bottom_screen.right;
293 res.top_screen.right = width - (width - viewport_width) / 2; 279 res.top_screen.right = res.top_screen.left + VideoCore::kScreenTopWidth;
294 res.top_screen.bottom = res.bottom_screen.bottom; 280 res.top_screen.bottom = height;
295 res.top_screen.top = res.top_screen.bottom - top_height; 281 res.top_screen.top = height - VideoCore::kScreenTopHeight;
296 } 282 }
297 283
298 return res; 284 return res;
@@ -309,4 +295,4 @@ FramebufferLayout SingleFrameLayout(unsigned width, unsigned height, bool is_swa
309FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool is_swapped) { 295FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool is_swapped) {
310 return is_swapped ? LargeFrameLayout_Swapped(width, height) : LargeFrameLayout(width, height); 296 return is_swapped ? LargeFrameLayout_Swapped(width, height) : LargeFrameLayout(width, height);
311} 297}
312} \ No newline at end of file 298}