diff options
author | ericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-16 02:43:24 +0000 |
---|---|---|
committer | ericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-16 02:43:24 +0000 |
commit | 50b8ee61c46bced3866f2646f37cbf9879d07027 (patch) | |
tree | 29a716cb570352a82dee3a0585fb02d0c5c1b4c3 /o3d/core | |
parent | 279456e2046383387f27c48cb003efa28d5e5f32 (diff) | |
download | chromium_src-50b8ee61c46bced3866f2646f37cbf9879d07027.zip chromium_src-50b8ee61c46bced3866f2646f37cbf9879d07027.tar.gz chromium_src-50b8ee61c46bced3866f2646f37cbf9879d07027.tar.bz2 |
Polish full-screen mode a bit:
* Add a just-use-the-current-display-mode flag.
* Make the sample use more parts of the API.
* Correct the spelling of full-screen as per Google's policy.
* Check for valid mode when the user gives it to us.
* Expose clearFullscreenClickRegion to JS.
* Fix a typo in convolution while I'm in there.
Review URL: http://codereview.chromium.org/126034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18477 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/core')
-rw-r--r-- | o3d/core/cross/renderer.h | 8 | ||||
-rw-r--r-- | o3d/core/win/d3d9/renderer_d3d9.cc | 29 |
2 files changed, 25 insertions, 12 deletions
diff --git a/o3d/core/cross/renderer.h b/o3d/core/cross/renderer.h index 3f96456..55ec2be 100644 --- a/o3d/core/cross/renderer.h +++ b/o3d/core/cross/renderer.h @@ -104,6 +104,14 @@ class Renderer { INITIALIZATION_ERROR, }; + // This is exposed to JavaScript, but as long as users always refer to it + // symbolically, it should be possible to change it without breaking anyone. + // NOTE: windows d3d display modes are internally implemented via adding 1 to + // their normal values of [0, NUM) so as not to collide with this value. + enum DisplayModes { + DISPLAY_MODE_DEFAULT = 0 + }; + // A StateHandler takes a param and sets or resets a render state. class StateHandler { public: diff --git a/o3d/core/win/d3d9/renderer_d3d9.cc b/o3d/core/win/d3d9/renderer_d3d9.cc index 0c3c5b2..8001043 100644 --- a/o3d/core/win/d3d9/renderer_d3d9.cc +++ b/o3d/core/win/d3d9/renderer_d3d9.cc @@ -1295,8 +1295,9 @@ void RendererD3D9::GetDisplayModes(std::vector<DisplayMode> *modes) { LOG(ERROR) << "Failed to enumerate adapter display modes."; } else { DCHECK(mode.Format == D3DFMT_X8R8G8B8); + // Display mode IDs are one higher than D3D display modes. modes_found.push_back( - DisplayMode(mode.Width, mode.Height, mode.RefreshRate, i)); + DisplayMode(mode.Width, mode.Height, mode.RefreshRate, i + 1)); } } modes->swap(modes_found); @@ -1304,10 +1305,17 @@ void RendererD3D9::GetDisplayModes(std::vector<DisplayMode> *modes) { bool RendererD3D9::GetDisplayMode(int id, DisplayMode *mode) { D3DDISPLAYMODE d3d_mode; - bool success = SUCCEEDED(d3d_->EnumAdapterModes(D3DADAPTER_DEFAULT, - D3DFMT_X8R8G8B8, - id, - &d3d_mode)); + bool success = false; + if (id == DISPLAY_MODE_DEFAULT) { + success = SUCCEEDED(d3d_->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, + &d3d_mode)); + } else { + // Display mode IDs are one higher than D3D display modes. + success = SUCCEEDED(d3d_->EnumAdapterModes(D3DADAPTER_DEFAULT, + D3DFMT_X8R8G8B8, + id - 1, + &d3d_mode)); + } if (success) { mode->Set(d3d_mode.Width, d3d_mode.Height, d3d_mode.RefreshRate, id); } @@ -1325,15 +1333,12 @@ bool RendererD3D9::SetFullscreen(bool fullscreen, int refresh_rate = 0; if (fullscreen) { // Look up the refresh rate. - D3DDISPLAYMODE mode; - if (FAILED(d3d_->EnumAdapterModes(D3DADAPTER_DEFAULT, - D3DFMT_X8R8G8B8, - mode_id, - &mode))) { - LOG(ERROR) << "Failed to EnumAdapterModes"; + DisplayMode mode; + if (!GetDisplayMode(mode_id, &mode)) { + LOG(ERROR) << "Failed to GetDisplayMode"; return false; } - refresh_rate = mode.RefreshRate; + refresh_rate = mode.refresh_rate(); showing_fullscreen_message_ = true; fullscreen_message_timer_.GetElapsedTimeAndReset(); // Reset the timer. } else { |