Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: core/win/d3d9/renderer_d3d9.cc

Issue 210005: Rewrote full-screen support on Windows. O3D now always creates its own... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « core/win/d3d9/renderer_d3d9.h ('k') | plugin/cross/o3d_glue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 SetupSoftwareRenderer(*d3d); 415 SetupSoftwareRenderer(*d3d);
416 416
417 ClientInfoManager* client_info_manager = 417 ClientInfoManager* client_info_manager =
418 service_locator->GetService<ClientInfoManager>(); 418 service_locator->GetService<ClientInfoManager>();
419 client_info_manager->SetSoftwareRenderer(true); 419 client_info_manager->SetSoftwareRenderer(true);
420 } 420 }
421 421
422 // Note: SwapEffect=DISCARD is req. for multisample to function 422 // Note: SwapEffect=DISCARD is req. for multisample to function
423 ZeroMemory(d3d_present_parameters, sizeof(*d3d_present_parameters)); 423 ZeroMemory(d3d_present_parameters, sizeof(*d3d_present_parameters));
424 d3d_present_parameters->Windowed = !fullscreen; 424 d3d_present_parameters->Windowed = !fullscreen;
425 d3d_present_parameters->hDeviceWindow = window;
425 d3d_present_parameters->SwapEffect = D3DSWAPEFFECT_DISCARD; 426 d3d_present_parameters->SwapEffect = D3DSWAPEFFECT_DISCARD;
426 d3d_present_parameters->BackBufferFormat = D3DFMT_A8R8G8B8; 427 d3d_present_parameters->BackBufferFormat = D3DFMT_A8R8G8B8;
427 d3d_present_parameters->EnableAutoDepthStencil = FALSE; 428 d3d_present_parameters->EnableAutoDepthStencil = FALSE;
428 d3d_present_parameters->AutoDepthStencilFormat = D3DFMT_D24S8; 429 d3d_present_parameters->AutoDepthStencilFormat = D3DFMT_D24S8;
429 d3d_present_parameters->EnableAutoDepthStencil = TRUE; 430 d3d_present_parameters->EnableAutoDepthStencil = TRUE;
430 // wait for vsync 431 // wait for vsync
431 d3d_present_parameters->PresentationInterval = D3DPRESENT_INTERVAL_ONE; 432 d3d_present_parameters->PresentationInterval = D3DPRESENT_INTERVAL_ONE;
432 433
433 if (features->not_anti_aliased() || ForceAntiAliasingOff(d3d)) { 434 if (features->not_anti_aliased() || ForceAntiAliasingOff(d3d)) {
434 d3d_present_parameters->MultiSampleType = D3DMULTISAMPLE_NONE; 435 d3d_present_parameters->MultiSampleType = D3DMULTISAMPLE_NONE;
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 D3DFMT_X8R8G8B8, 1325 D3DFMT_X8R8G8B8,
1325 id - 1, 1326 id - 1,
1326 &d3d_mode)); 1327 &d3d_mode));
1327 } 1328 }
1328 if (success) { 1329 if (success) {
1329 mode->Set(d3d_mode.Width, d3d_mode.Height, d3d_mode.RefreshRate, id); 1330 mode->Set(d3d_mode.Width, d3d_mode.Height, d3d_mode.RefreshRate, id);
1330 } 1331 }
1331 return success; 1332 return success;
1332 } 1333 }
1333 1334
1334 bool RendererD3D9::SetFullscreen(bool fullscreen, 1335 bool RendererD3D9::GoFullscreen(const DisplayWindow& display,
1335 const DisplayWindow& display, 1336 int mode_id) {
1336 int mode_id) { 1337 if (!fullscreen_) {
1337 if (fullscreen != fullscreen_) {
1338 if (d3d_device_) { // Have we been initialized yet? 1338 if (d3d_device_) { // Have we been initialized yet?
1339 const DisplayWindowWindows& platform_display = 1339 const DisplayWindowWindows& platform_display =
1340 static_cast<const DisplayWindowWindows&>(display); 1340 static_cast<const DisplayWindowWindows&>(display);
1341 HWND window = platform_display.hwnd(); 1341 HWND window = platform_display.hwnd();
1342 int refresh_rate = 0; 1342 int refresh_rate = 0;
1343 bool windowed = true; 1343 bool windowed = true;
1344 if (fullscreen) { 1344
1345 // If fullscreen is requested but the mode is set to 1345 // Look up the refresh rate, width and height.
1346 // DISPLAY_MODE_DEFAULT then create a non-full-screen window at the 1346 DisplayMode mode;
1347 // current display resolution. If any other mode is chosen then the 1347 if (!GetDisplayMode(mode_id, &mode)) {
1348 // windows will change mode and create a true full-screen window. 1348 LOG(ERROR) << "Failed to GetDisplayMode";
1349 if (mode_id != DISPLAY_MODE_DEFAULT) { 1349 return false;
1350 // Look up the refresh rate.
1351 DisplayMode mode;
1352 if (!GetDisplayMode(mode_id, &mode)) {
1353 LOG(ERROR) << "Failed to GetDisplayMode";
1354 return false;
1355 }
1356 refresh_rate = mode.refresh_rate();
1357 windowed = false;
1358 }
1359 showing_fullscreen_message_ = true;
1360 fullscreen_message_timer_.GetElapsedTimeAndReset(); // Reset the timer.
1361 } else {
1362 showing_fullscreen_message_ = false;
1363 } 1350 }
1351
1352 int width = mode.width();
1353 int height = mode.height();
1354
1355 // If fullscreen is requested but the mode is set to
1356 // DISPLAY_MODE_DEFAULT then create a non-full-screen window at the
1357 // current display resolution. If any other mode is chosen then the
1358 // windows will change mode and create a true full-screen window.
1359 if (mode_id != DISPLAY_MODE_DEFAULT) {
1360 refresh_rate = mode.refresh_rate();
1361 windowed = false;
1362 }
1363
1364 showing_fullscreen_message_ = true;
1365 fullscreen_message_timer_.GetElapsedTimeAndReset(); // Reset the timer.
1366
1364 d3d_present_parameters_.FullScreen_RefreshRateInHz = refresh_rate; 1367 d3d_present_parameters_.FullScreen_RefreshRateInHz = refresh_rate;
1365 d3d_present_parameters_.hDeviceWindow = window; 1368 d3d_present_parameters_.hDeviceWindow = window;
1366 d3d_present_parameters_.Windowed = windowed; 1369 d3d_present_parameters_.Windowed = windowed;
1367 1370
1368 // Check if the window size is zero. Some drivers will fail because of 1371 // Check if the window size is zero. Some drivers will fail because of
1369 // that so we'll force a small size in that case. 1372 // that so we'll force a small size in that case.
1370 RECT windowRect;
1371 ::GetWindowRect(window, &windowRect);
1372 int width = windowRect.right - windowRect.left;
1373 int height = windowRect.bottom - windowRect.top;
1374
1375 if (width == 0 || height == 0) { 1373 if (width == 0 || height == 0) {
1376 width = 16; 1374 width = 16;
1377 height = 16; 1375 height = 16;
1378 } 1376 }
1379 fullscreen_ = fullscreen; 1377 fullscreen_ = true;
1380 Resize(width, height); 1378 Resize(width, height);
1381 } 1379 }
1382 } 1380 }
1381 return true;
1382 }
1383
1384 bool RendererD3D9::CancelFullscreen(const DisplayWindow& display,
1385 int width,
1386 int height) {
1387 if (fullscreen_) {
1388 if (d3d_device_) { // Have we been initialized yet?
1389 const DisplayWindowWindows& platform_display =
1390 static_cast<const DisplayWindowWindows&>(display);
1391 HWND window = platform_display.hwnd();
1392 showing_fullscreen_message_ = false;
1393 d3d_present_parameters_.FullScreen_RefreshRateInHz = 0;
1394 d3d_present_parameters_.hDeviceWindow = window;
1395 d3d_present_parameters_.Windowed = true;
1396
1397 // Check if the window size is zero. Some drivers will fail because of
1398 // that so we'll force a small size in that case.
1399 if (width == 0 || height == 0) {
1400 width = 16;
1401 height = 16;
1402 }
1403 fullscreen_ = false;
1404 Resize(width, height);
1405 }
1406 }
1383 return true; 1407 return true;
1384 } 1408 }
1385 1409
1386 // Resets the rendering stats and 1410 // Resets the rendering stats and
1387 bool RendererD3D9::PlatformSpecificStartRendering() { 1411 bool RendererD3D9::PlatformSpecificStartRendering() {
1388 // Determine whether the device is lost, resetting if possible. 1412 // Determine whether the device is lost, resetting if possible.
1389 TestLostDevice(); 1413 TestLostDevice();
1390 1414
1391 bool result = have_device_; 1415 bool result = have_device_;
1392 if (result) { 1416 if (result) {
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 static int swizzle_table[] = { 2, 1, 0, 3, }; 1655 static int swizzle_table[] = { 2, 1, 0, 3, };
1632 return swizzle_table; 1656 return swizzle_table;
1633 } 1657 }
1634 1658
1635 // This is a factory function for creating Renderer objects. Since 1659 // This is a factory function for creating Renderer objects. Since
1636 // we're implementing D3D9, we only ever return a D3D9 renderer. 1660 // we're implementing D3D9, we only ever return a D3D9 renderer.
1637 Renderer* Renderer::CreateDefaultRenderer(ServiceLocator* service_locator) { 1661 Renderer* Renderer::CreateDefaultRenderer(ServiceLocator* service_locator) {
1638 return RendererD3D9::CreateDefault(service_locator); 1662 return RendererD3D9::CreateDefault(service_locator);
1639 } 1663 }
1640 } // namespace o3d 1664 } // namespace o3d
OLDNEW
« no previous file with comments | « core/win/d3d9/renderer_d3d9.h ('k') | plugin/cross/o3d_glue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698