OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_GL_GL_SURFACE_GLX_H_ | 5 #ifndef UI_GL_GL_SURFACE_GLX_H_ |
6 #define UI_GL_GL_SURFACE_GLX_H_ | 6 #define UI_GL_GL_SURFACE_GLX_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "ui/base/x/x11_util.h" | 10 #include "ui/base/x/x11_util.h" |
11 #include "ui/gfx/native_widget_types.h" | 11 #include "ui/gfx/native_widget_types.h" |
12 #include "ui/gfx/size.h" | 12 #include "ui/gfx/size.h" |
13 #include "ui/gl/gl_export.h" | 13 #include "ui/gl/gl_export.h" |
14 #include "ui/gl/gl_surface.h" | 14 #include "ui/gl/gl_surface.h" |
15 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 | 17 |
18 // Base class for GLX surfaces. | 18 // Base class for GLX surfaces. |
19 class GL_EXPORT GLSurfaceGLX : public GLSurface { | 19 class GL_EXPORT GLSurfaceGLX : public GLSurface { |
20 public: | 20 public: |
21 GLSurfaceGLX(); | 21 GLSurfaceGLX(); |
22 virtual ~GLSurfaceGLX(); | |
23 | 22 |
24 static bool InitializeOneOff(); | 23 static bool InitializeOneOff(); |
25 | 24 |
26 // These aren't particularly tied to surfaces, but since we already | 25 // These aren't particularly tied to surfaces, but since we already |
27 // have the static InitializeOneOff here, it's easiest to reuse its | 26 // have the static InitializeOneOff here, it's easiest to reuse its |
28 // initialization guards. | 27 // initialization guards. |
29 static const char* GetGLXExtensions(); | 28 static const char* GetGLXExtensions(); |
30 static bool HasGLXExtension(const char* name); | 29 static bool HasGLXExtension(const char* name); |
31 static bool IsCreateContextRobustnessSupported(); | 30 static bool IsCreateContextRobustnessSupported(); |
32 | 31 |
33 virtual void* GetDisplay() OVERRIDE; | 32 virtual void* GetDisplay() OVERRIDE; |
34 | 33 |
35 // Get the FB config that the surface was created with or NULL if it is not | 34 // Get the FB config that the surface was created with or NULL if it is not |
36 // a GLX drawable. | 35 // a GLX drawable. |
37 virtual void* GetConfig() = 0; | 36 virtual void* GetConfig() = 0; |
38 | 37 |
| 38 protected: |
| 39 virtual ~GLSurfaceGLX(); |
| 40 |
39 private: | 41 private: |
40 DISALLOW_COPY_AND_ASSIGN(GLSurfaceGLX); | 42 DISALLOW_COPY_AND_ASSIGN(GLSurfaceGLX); |
41 }; | 43 }; |
42 | 44 |
43 // A surface used to render to a view. | 45 // A surface used to render to a view. |
44 class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX { | 46 class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX { |
45 public: | 47 public: |
46 explicit NativeViewGLSurfaceGLX(gfx::AcceleratedWidget window); | 48 explicit NativeViewGLSurfaceGLX(gfx::AcceleratedWidget window); |
47 virtual ~NativeViewGLSurfaceGLX(); | |
48 | 49 |
49 // Implement GLSurfaceGLX. | 50 // Implement GLSurfaceGLX. |
50 virtual bool Initialize() OVERRIDE; | 51 virtual bool Initialize() OVERRIDE; |
51 virtual void Destroy() OVERRIDE; | 52 virtual void Destroy() OVERRIDE; |
52 virtual bool Resize(const gfx::Size& size) OVERRIDE; | 53 virtual bool Resize(const gfx::Size& size) OVERRIDE; |
53 virtual bool IsOffscreen() OVERRIDE; | 54 virtual bool IsOffscreen() OVERRIDE; |
54 virtual bool SwapBuffers() OVERRIDE; | 55 virtual bool SwapBuffers() OVERRIDE; |
55 virtual gfx::Size GetSize() OVERRIDE; | 56 virtual gfx::Size GetSize() OVERRIDE; |
56 virtual void* GetHandle() OVERRIDE; | 57 virtual void* GetHandle() OVERRIDE; |
57 virtual std::string GetExtensions() OVERRIDE; | 58 virtual std::string GetExtensions() OVERRIDE; |
58 virtual void* GetConfig() OVERRIDE; | 59 virtual void* GetConfig() OVERRIDE; |
59 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; | 60 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; |
60 | 61 |
61 protected: | 62 protected: |
62 NativeViewGLSurfaceGLX(); | 63 NativeViewGLSurfaceGLX(); |
| 64 virtual ~NativeViewGLSurfaceGLX(); |
63 | 65 |
64 gfx::AcceleratedWidget window_; | 66 gfx::AcceleratedWidget window_; |
65 | 67 |
66 private: | 68 private: |
67 void* config_; | 69 void* config_; |
68 gfx::Size size_; | 70 gfx::Size size_; |
69 | 71 |
70 DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceGLX); | 72 DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceGLX); |
71 }; | 73 }; |
72 | 74 |
73 // A surface used to render to an offscreen pbuffer. | 75 // A surface used to render to an offscreen pbuffer. |
74 class GL_EXPORT PbufferGLSurfaceGLX : public GLSurfaceGLX { | 76 class GL_EXPORT PbufferGLSurfaceGLX : public GLSurfaceGLX { |
75 public: | 77 public: |
76 explicit PbufferGLSurfaceGLX(const gfx::Size& size); | 78 explicit PbufferGLSurfaceGLX(const gfx::Size& size); |
77 virtual ~PbufferGLSurfaceGLX(); | |
78 | 79 |
79 // Implement GLSurfaceGLX. | 80 // Implement GLSurfaceGLX. |
80 virtual bool Initialize() OVERRIDE; | 81 virtual bool Initialize() OVERRIDE; |
81 virtual void Destroy() OVERRIDE; | 82 virtual void Destroy() OVERRIDE; |
82 virtual bool IsOffscreen() OVERRIDE; | 83 virtual bool IsOffscreen() OVERRIDE; |
83 virtual bool SwapBuffers() OVERRIDE; | 84 virtual bool SwapBuffers() OVERRIDE; |
84 virtual gfx::Size GetSize() OVERRIDE; | 85 virtual gfx::Size GetSize() OVERRIDE; |
85 virtual void* GetHandle() OVERRIDE; | 86 virtual void* GetHandle() OVERRIDE; |
86 virtual void* GetConfig() OVERRIDE; | 87 virtual void* GetConfig() OVERRIDE; |
87 | 88 |
| 89 protected: |
| 90 virtual ~PbufferGLSurfaceGLX(); |
| 91 |
88 private: | 92 private: |
89 gfx::Size size_; | 93 gfx::Size size_; |
90 void* config_; | 94 void* config_; |
91 XID pbuffer_; | 95 XID pbuffer_; |
92 | 96 |
93 DISALLOW_COPY_AND_ASSIGN(PbufferGLSurfaceGLX); | 97 DISALLOW_COPY_AND_ASSIGN(PbufferGLSurfaceGLX); |
94 }; | 98 }; |
95 | 99 |
96 } // namespace gfx | 100 } // namespace gfx |
97 | 101 |
98 #endif // UI_GL_GL_SURFACE_GLX_H_ | 102 #endif // UI_GL_GL_SURFACE_GLX_H_ |
OLD | NEW |