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_SURFACE_H_ | 5 #ifndef UI_GFX_GL_GL_SURFACE_H_ |
6 #define UI_GFX_GL_GL_SURFACE_H_ | 6 #define UI_GFX_GL_GL_SURFACE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 // (Re)create the surface. TODO(apatrick): This is an ugly hack to allow the | 25 // (Re)create the surface. TODO(apatrick): This is an ugly hack to allow the |
26 // EGL surface associated to be recreated without destroying the associated | 26 // EGL surface associated to be recreated without destroying the associated |
27 // context. The implementation of this function for other GLSurface derived | 27 // context. The implementation of this function for other GLSurface derived |
28 // classes is in a pending changelist. | 28 // classes is in a pending changelist. |
29 virtual bool Initialize(); | 29 virtual bool Initialize(); |
30 | 30 |
31 // Destroys the surface. | 31 // Destroys the surface. |
32 virtual void Destroy() = 0; | 32 virtual void Destroy() = 0; |
33 | 33 |
| 34 virtual bool Resize(const gfx::Size& size); |
| 35 |
34 // Returns true if this surface is offscreen. | 36 // Returns true if this surface is offscreen. |
35 virtual bool IsOffscreen() = 0; | 37 virtual bool IsOffscreen() = 0; |
36 | 38 |
37 // Swaps front and back buffers. This has no effect for off-screen | 39 // Swaps front and back buffers. This has no effect for off-screen |
38 // contexts. | 40 // contexts. |
39 virtual bool SwapBuffers() = 0; | 41 virtual bool SwapBuffers() = 0; |
40 | 42 |
41 // Get the size of the surface. | 43 // Get the size of the surface. |
42 virtual gfx::Size GetSize() = 0; | 44 virtual gfx::Size GetSize() = 0; |
43 | 45 |
44 // Get the underlying platform specific surface "handle". | 46 // Get the underlying platform specific surface "handle". |
45 virtual void* GetHandle() = 0; | 47 virtual void* GetHandle() = 0; |
46 | 48 |
47 // Returns the internal frame buffer object name if the surface is backed by | 49 // Returns the internal frame buffer object name if the surface is backed by |
48 // FBO. Otherwise returns 0. | 50 // FBO. Otherwise returns 0. |
49 virtual unsigned int GetBackingFrameBufferObject(); | 51 virtual unsigned int GetBackingFrameBufferObject(); |
50 | 52 |
51 static bool InitializeOneOff(); | 53 static bool InitializeOneOff(); |
52 | 54 |
53 // Called after a context is made current with this surface. Returns false | 55 // Called after a context is made current with this surface. Returns false |
54 // on error. | 56 // on error. |
55 virtual bool OnMakeCurrent(GLContext* context); | 57 virtual bool OnMakeCurrent(GLContext* context); |
56 | 58 |
| 59 // This gives a hint as to whether this surface is visible. If it is not |
| 60 // visible, the backing store need not be preserved. |
57 virtual void SetVisible(bool visible); | 61 virtual void SetVisible(bool visible); |
58 | 62 |
| 63 // Get a handle used to share the surface with another process. Returns null |
| 64 // if this is not possible. |
| 65 virtual void* GetShareHandle(); |
| 66 |
| 67 // Get the platform specific display on which this surface resides, if |
| 68 // available. |
| 69 virtual void* GetDisplay(); |
| 70 |
| 71 // Get the platfrom specific configuration for this surface, if available. |
| 72 virtual void* GetConfig(); |
| 73 |
| 74 // Get the GL pixel format of the surface, if available. |
| 75 virtual unsigned GetFormat(); |
| 76 |
59 // Create a GL surface that renders directly to a view. | 77 // Create a GL surface that renders directly to a view. |
60 static scoped_refptr<GLSurface> CreateViewGLSurface( | 78 static scoped_refptr<GLSurface> CreateViewGLSurface( |
61 bool software, | 79 bool software, |
62 gfx::PluginWindowHandle window); | 80 gfx::PluginWindowHandle window); |
63 | 81 |
64 // Create a GL surface used for offscreen rendering. | 82 // Create a GL surface used for offscreen rendering. |
65 static scoped_refptr<GLSurface> CreateOffscreenGLSurface( | 83 static scoped_refptr<GLSurface> CreateOffscreenGLSurface( |
66 bool software, | 84 bool software, |
67 const gfx::Size& size); | 85 const gfx::Size& size); |
68 | 86 |
69 static GLSurface* GetCurrent(); | 87 static GLSurface* GetCurrent(); |
70 | 88 |
71 protected: | 89 protected: |
72 virtual ~GLSurface(); | 90 virtual ~GLSurface(); |
73 static void SetCurrent(GLSurface* surface); | 91 static void SetCurrent(GLSurface* surface); |
74 | 92 |
75 private: | 93 private: |
76 friend class base::RefCounted<GLSurface>; | 94 friend class base::RefCounted<GLSurface>; |
77 friend class GLContext; | 95 friend class GLContext; |
78 DISALLOW_COPY_AND_ASSIGN(GLSurface); | 96 DISALLOW_COPY_AND_ASSIGN(GLSurface); |
79 }; | 97 }; |
80 | 98 |
| 99 // Implementation of GLSurface that forwards all calls through to another |
| 100 // GLSurface. |
| 101 class GL_EXPORT GLSurfaceAdapter : public GLSurface { |
| 102 public: |
| 103 explicit GLSurfaceAdapter(GLSurface* surface); |
| 104 virtual ~GLSurfaceAdapter(); |
| 105 |
| 106 virtual bool Initialize(); |
| 107 virtual void Destroy(); |
| 108 virtual bool Resize(const gfx::Size& size); |
| 109 virtual bool IsOffscreen(); |
| 110 virtual bool SwapBuffers(); |
| 111 virtual gfx::Size GetSize(); |
| 112 virtual void* GetHandle(); |
| 113 virtual unsigned int GetBackingFrameBufferObject(); |
| 114 virtual bool OnMakeCurrent(GLContext* context); |
| 115 virtual void* GetShareHandle(); |
| 116 virtual void* GetDisplay(); |
| 117 virtual void* GetConfig(); |
| 118 virtual unsigned GetFormat(); |
| 119 |
| 120 GLSurface* surface() const { return surface_.get(); } |
| 121 |
| 122 private: |
| 123 scoped_refptr<GLSurface> surface_; |
| 124 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); |
| 125 }; |
| 126 |
81 } // namespace gfx | 127 } // namespace gfx |
82 | 128 |
83 #endif // UI_GFX_GL_GL_SURFACE_H_ | 129 #endif // UI_GFX_GL_GL_SURFACE_H_ |
OLD | NEW |