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