diff options
author | tschmelcher@google.com <tschmelcher@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-01 17:30:15 +0000 |
---|---|---|
committer | tschmelcher@google.com <tschmelcher@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-01 17:30:15 +0000 |
commit | f6618de512037e7f9701b03877f53868c47e01dc (patch) | |
tree | fcb95d8fb48791a22e6ff2e5ef5779ce265294ad /o3d/core | |
parent | 6b5a32b508a41b4b1e19d7ec1815ce4f6b2e1699 (diff) | |
download | chromium_src-f6618de512037e7f9701b03877f53868c47e01dc.zip chromium_src-f6618de512037e7f9701b03877f53868c47e01dc.tar.gz chromium_src-f6618de512037e7f9701b03877f53868c47e01dc.tar.bz2 |
Implement fullscreen on Linux. No "Press Esc" message yet though. Also it's DISPLAY_MODE_DEFAULT only for now (mode switching is evil anyways ;) ). Small bit of code cleanup in renderer.h.
TESTED=entered and exited fullscreen; tested leaving with Esc, Alt+F4, click on region, and right-click on taskbare -> Close; all with both Compiz on and off, on gHardy.
Review URL: http://codereview.chromium.org/258004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27732 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/core')
-rw-r--r-- | o3d/core/cross/gl/renderer_gl.cc | 52 | ||||
-rw-r--r-- | o3d/core/cross/gl/renderer_gl.h | 8 | ||||
-rw-r--r-- | o3d/core/cross/renderer.h | 23 |
3 files changed, 66 insertions, 17 deletions
diff --git a/o3d/core/cross/gl/renderer_gl.cc b/o3d/core/cross/gl/renderer_gl.cc index 02a6942..0e2f683 100644 --- a/o3d/core/cross/gl/renderer_gl.cc +++ b/o3d/core/cross/gl/renderer_gl.cc @@ -1214,16 +1214,68 @@ void RendererGL::Resize(int width, int height) { bool RendererGL::GoFullscreen(const DisplayWindow& display, int mode_id) { +#ifdef OS_LINUX + // This actually just switches the GLX context to the new window. The real + // work is in main_linux.cc. + const DisplayWindowLinux &display_platform = + static_cast<const DisplayWindowLinux&>(display); + display_ = display_platform.display(); + window_ = display_platform.window(); + if (!MakeCurrent()) { + return false; + } +#endif fullscreen_ = true; return true; } bool RendererGL::CancelFullscreen(const DisplayWindow& display, int width, int height) { +#ifdef OS_LINUX + // This actually just switches the GLX context to the old window. The real + // work is in main_linux.cc. + const DisplayWindowLinux &display_platform = + static_cast<const DisplayWindowLinux&>(display); + display_ = display_platform.display(); + window_ = display_platform.window(); + if (!MakeCurrent()) { + return false; + } +#endif fullscreen_ = false; return true; } +void RendererGL::GetDisplayModes(std::vector<DisplayMode> *modes) { +#ifdef OS_MACOSX + // Mac is supposed to call a different function in plugin_mac.mm instead. + DLOG(FATAL) << "Not supposed to be called"; +#endif + // On all other platforms this is unimplemented. Linux only supports + // DISPLAY_MODE_DEFAULT for now. + modes->clear(); +} + +bool RendererGL::GetDisplayMode(int id, DisplayMode *mode) { +#ifdef OS_MACOSX + // Mac is supposed to call a different function in plugin_mac.mm instead. + DLOG(FATAL) << "Not supposed to be called"; + return false; +#elif defined(OS_LINUX) + if (id == DISPLAY_MODE_DEFAULT) { + // Don't need to know any of this on Linux. + mode->Set(0, 0, 0, id); + return true; + } else { + // There are no other valid ids until we implement GetDisplayModes() and + // mode switching. + return false; + } +#else + return false; +#endif +} + bool RendererGL::PlatformSpecificStartRendering() { DLOG_FIRST_N(INFO, 10) << "RendererGL StartRendering"; MakeCurrentLazy(); diff --git a/o3d/core/cross/gl/renderer_gl.h b/o3d/core/cross/gl/renderer_gl.h index 722e29e2..de2a8cb 100644 --- a/o3d/core/cross/gl/renderer_gl.h +++ b/o3d/core/cross/gl/renderer_gl.h @@ -78,6 +78,14 @@ class RendererGL : public Renderer { return fullscreen_; } + // Get a vector of the available fullscreen display modes. + // Clears *modes on error. + virtual void GetDisplayModes(std::vector<DisplayMode> *modes); + + // Get a single fullscreen display mode by id. + // Returns true on success, false on error. + virtual bool GetDisplayMode(int id, DisplayMode *mode); + // Resizes the viewport in OpenGL. virtual void Resize(int width, int height); diff --git a/o3d/core/cross/renderer.h b/o3d/core/cross/renderer.h index c372bca..f299886 100644 --- a/o3d/core/cross/renderer.h +++ b/o3d/core/cross/renderer.h @@ -218,11 +218,8 @@ class Renderer { // display: a platform-specific display identifier // mode_id: a mode returned by GetDisplayModes // Returns true on success, false on failure. - // TODO(o3d): Make this pure virtual once it's implemented everywhere. virtual bool GoFullscreen(const DisplayWindow& display, - int mode_id) { - return false; - } + int mode_id) = 0; // Cancels fullscreen display. Restores rendering to windowed mode // with the given width and height. @@ -231,27 +228,19 @@ class Renderer { // width: the width to which to restore windowed rendering // height: the height to which to restore windowed rendering // Returns true on success, false on failure. - // TODO(o3d): Make this pure virtual once it's implemented everywhere. virtual bool CancelFullscreen(const DisplayWindow& display, - int width, int height) { - return false; - } + int width, int height) = 0; // Tells whether we're currently displayed fullscreen or not. - virtual bool fullscreen() const { return false; } + virtual bool fullscreen() const = 0; // Get a vector of the available fullscreen display modes. // Clears *modes on error. - // TODO: Make this pure virtual once it's implemented everywhere. - virtual void GetDisplayModes(std::vector<DisplayMode> *modes) { - modes->clear(); - } + virtual void GetDisplayModes(std::vector<DisplayMode> *modes) = 0; + // Get a single fullscreen display mode by id. // Returns true on success, false on error. - // TODO: Make this pure virtual once it's implemented everywhere. - virtual bool GetDisplayMode(int id, DisplayMode *mode) { - return false; - } + virtual bool GetDisplayMode(int id, DisplayMode *mode) = 0; // Gets the viewport. void GetViewport(Float4* rectangle, Float2* depth_range); |