diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-14 00:11:59 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-14 00:11:59 +0000 |
commit | 24edbd0b34b7177a781da8f5d0bbf4121d692b31 (patch) | |
tree | bf2e9f5b9e21ad74b358e48821d0dc1d63bb700c /ui/gfx/gl/gl_surface.h | |
parent | 866940781aa790de0a1e35f5d76163198e85e11c (diff) | |
download | chromium_src-24edbd0b34b7177a781da8f5d0bbf4121d692b31.zip chromium_src-24edbd0b34b7177a781da8f5d0bbf4121d692b31.tar.gz chromium_src-24edbd0b34b7177a781da8f5d0bbf4121d692b31.tar.bz2 |
Split EGLContext in GLContextEGL and GLSurfaceEGL.
Surfaces are independent of contexts in GL. To facilitate sharing of surfaces between processes, I have separated them from the notion of contexts because contexts cannot be shared between processes.
I have started with EGL. GLContextEGL still has a pointer to a surface and still has some surface specific operations that just forward through to it. Once I have refactored all the GLContext implementations in this way, I will remove these pointers and the surface specific opertations.
There will not be "view" and "offscreen" GL contexts. Rather there will be a single context type for each backend which can be made current with a surface that directs output either to a view or offscreen surface.
TEST=try, WebGL puppy works
BUG=none
Review URL: http://codereview.chromium.org/6839008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81512 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/gl/gl_surface.h')
-rw-r--r-- | ui/gfx/gl/gl_surface.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/ui/gfx/gl/gl_surface.h b/ui/gfx/gl/gl_surface.h new file mode 100644 index 0000000..c0ab1e9 --- /dev/null +++ b/ui/gfx/gl/gl_surface.h @@ -0,0 +1,56 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_GFX_GL_GL_SURFACE_H_ +#define UI_GFX_GL_GL_SURFACE_H_ +#pragma once + +#include "build/build_config.h" +#include "ui/gfx/native_widget_types.h" +#include "ui/gfx/size.h" + +namespace gfx { + +// Encapsulates a surface that can be rendered to with GL, hiding platform +// specific management. +class GLSurface { + public: + GLSurface() {} + virtual ~GLSurface() {} + + // Destroys the surface. + virtual void Destroy() = 0; + + // Returns true if this surface is offscreen. + virtual bool IsOffscreen() = 0; + + // Swaps front and back buffers. This has no effect for off-screen + // contexts. + virtual bool SwapBuffers() = 0; + + // Get the size of the surface. + virtual gfx::Size GetSize() = 0; + + // Get the underlying platform specific surface "handle". + virtual void* GetHandle() = 0; + + // Returns the internal frame buffer object name if the surface is backed by + // FBO. Otherwise returns 0. + virtual unsigned int GetBackingFrameBufferObject(); + +#if !defined(OS_MACOSX) + // Create a surface corresponding to a view. + static GLSurface* CreateViewGLContext(gfx::PluginWindowHandle window); +#endif + + // Create a surface used for offscreen rendering. + static GLSurface* CreateOffscreenGLContext(const gfx::Size& size); + + private: + DISALLOW_COPY_AND_ASSIGN(GLSurface); +}; + +} // namespace gfx + +#endif // UI_GFX_GL_GL_SURFACE_H_ |