| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_GFX_GL_GL_CONTEXT_H_ | 5 #ifndef UI_GFX_GL_GL_SURFACE_H_ |
| 6 #define UI_GFX_GL_GL_CONTEXT_H_ | 6 #define UI_GFX_GL_GL_SURFACE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | |
| 10 | |
| 11 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 12 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
| 13 #include "ui/gfx/size.h" | 11 #include "ui/gfx/size.h" |
| 14 | 12 |
| 15 namespace gfx { | 13 namespace gfx { |
| 16 | 14 |
| 17 // Encapsulates an OpenGL context, hiding platform specific management. | 15 // Encapsulates a surface that can be rendered to with GL, hiding platform |
| 18 class GLContext { | 16 // specific management. |
| 17 class GLSurface { |
| 19 public: | 18 public: |
| 20 GLContext() {} | 19 GLSurface() {} |
| 21 virtual ~GLContext() {} | 20 virtual ~GLSurface() {} |
| 22 | 21 |
| 23 // Destroys the GL context. | 22 // Destroys the surface. |
| 24 virtual void Destroy() = 0; | 23 virtual void Destroy() = 0; |
| 25 | 24 |
| 26 // Makes the GL context current on the current thread. | 25 // Returns true if this surface is offscreen. |
| 27 virtual bool MakeCurrent() = 0; | |
| 28 | |
| 29 // Returns true if this context is current. | |
| 30 virtual bool IsCurrent() = 0; | |
| 31 | |
| 32 // Returns true if this context is offscreen. | |
| 33 virtual bool IsOffscreen() = 0; | 26 virtual bool IsOffscreen() = 0; |
| 34 | 27 |
| 35 // Swaps front and back buffers. This has no effect for off-screen | 28 // Swaps front and back buffers. This has no effect for off-screen |
| 36 // contexts. | 29 // contexts. |
| 37 virtual bool SwapBuffers() = 0; | 30 virtual bool SwapBuffers() = 0; |
| 38 | 31 |
| 39 // Get the size of the back buffer. | 32 // Get the size of the surface. |
| 40 virtual gfx::Size GetSize() = 0; | 33 virtual gfx::Size GetSize() = 0; |
| 41 | 34 |
| 42 // Get the underlying platform specific GL context "handle". | 35 // Get the underlying platform specific surface "handle". |
| 43 virtual void* GetHandle() = 0; | 36 virtual void* GetHandle() = 0; |
| 44 | 37 |
| 45 // Set swap interval. This context must be current. | 38 // Returns the internal frame buffer object name if the surface is backed by |
| 46 virtual void SetSwapInterval(int interval) = 0; | |
| 47 | |
| 48 // Returns the internal frame buffer object name if the context is backed by | |
| 49 // FBO. Otherwise returns 0. | 39 // FBO. Otherwise returns 0. |
| 50 virtual unsigned int GetBackingFrameBufferObject(); | 40 virtual unsigned int GetBackingFrameBufferObject(); |
| 51 | 41 |
| 52 // Returns space separated list of extensions. The context must be current. | |
| 53 virtual std::string GetExtensions(); | |
| 54 | |
| 55 // Returns whether the current context supports the named extension. The | |
| 56 // context must be current. | |
| 57 bool HasExtension(const char* name); | |
| 58 | |
| 59 static bool InitializeOneOff(); | |
| 60 | |
| 61 #if !defined(OS_MACOSX) | 42 #if !defined(OS_MACOSX) |
| 62 // Create a GL context that renders directly to a view. | 43 // Create a surface corresponding to a view. |
| 63 static GLContext* CreateViewGLContext(gfx::PluginWindowHandle window, | 44 static GLSurface* CreateViewGLContext(gfx::PluginWindowHandle window); |
| 64 bool multisampled); | |
| 65 #endif | 45 #endif |
| 66 | 46 |
| 67 // Create a GL context used for offscreen rendering. It is initially backed by | 47 // Create a surface used for offscreen rendering. |
| 68 // a 1x1 pbuffer. Use it to create an FBO to do useful rendering. | 48 static GLSurface* CreateOffscreenGLContext(const gfx::Size& size); |
| 69 // |share_context|, if non-NULL, is a context which the internally created | |
| 70 // OpenGL context shares textures and other resources. | |
| 71 static GLContext* CreateOffscreenGLContext(GLContext* shared_context); | |
| 72 | |
| 73 protected: | |
| 74 bool InitializeCommon(); | |
| 75 | 49 |
| 76 private: | 50 private: |
| 77 DISALLOW_COPY_AND_ASSIGN(GLContext); | 51 DISALLOW_COPY_AND_ASSIGN(GLSurface); |
| 78 }; | 52 }; |
| 79 | 53 |
| 80 } // namespace gfx | 54 } // namespace gfx |
| 81 | 55 |
| 82 #endif // UI_GFX_GL_GL_CONTEXT_H_ | 56 #endif // UI_GFX_GL_GL_SURFACE_H_ |
| OLD | NEW |