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.
5 #ifndef UI_GL_GL_SURFACE_GLX_H_
6 #define UI_GL_GL_SURFACE_GLX_H_
10 #include "base/compiler_specific.h"
11 #include "ui/base/x/x11_util.h"
12 #include "ui/gfx/native_widget_types.h"
13 #include "ui/gfx/size.h"
14 #include "ui/gl/gl_export.h"
15 #include "ui/gl/gl_surface.h"
16 #include "ui/gl/vsync_provider.h"
20 // Base class for GLX surfaces.
21 class GL_EXPORT GLSurfaceGLX
: public GLSurface
{
25 static bool InitializeOneOff();
27 // These aren't particularly tied to surfaces, but since we already
28 // have the static InitializeOneOff here, it's easiest to reuse its
29 // initialization guards.
30 static const char* GetGLXExtensions();
31 static bool HasGLXExtension(const char* name
);
32 static bool IsCreateContextSupported();
33 static bool IsCreateContextRobustnessSupported();
34 static bool IsTextureFromPixmapSupported();
35 static bool IsOMLSyncControlSupported();
37 virtual void* GetDisplay() OVERRIDE
;
39 // Get the FB config that the surface was created with or NULL if it is not
41 virtual void* GetConfig() = 0;
44 virtual ~GLSurfaceGLX();
47 DISALLOW_COPY_AND_ASSIGN(GLSurfaceGLX
);
50 // A surface used to render to a view.
51 class GL_EXPORT NativeViewGLSurfaceGLX
: public GLSurfaceGLX
{
53 explicit NativeViewGLSurfaceGLX(gfx::AcceleratedWidget window
);
55 // Implement GLSurfaceGLX.
56 virtual bool Initialize() OVERRIDE
;
57 virtual void Destroy() OVERRIDE
;
58 virtual bool Resize(const gfx::Size
& size
) OVERRIDE
;
59 virtual bool IsOffscreen() OVERRIDE
;
60 virtual bool SwapBuffers() OVERRIDE
;
61 virtual gfx::Size
GetSize() OVERRIDE
;
62 virtual void* GetHandle() OVERRIDE
;
63 virtual std::string
GetExtensions() OVERRIDE
;
64 virtual void* GetConfig() OVERRIDE
;
65 virtual bool PostSubBuffer(int x
, int y
, int width
, int height
) OVERRIDE
;
66 virtual VSyncProvider
* GetVSyncProvider() OVERRIDE
;
69 NativeViewGLSurfaceGLX();
70 virtual ~NativeViewGLSurfaceGLX();
72 gfx::AcceleratedWidget window_
;
78 scoped_ptr
<VSyncProvider
> vsync_provider_
;
80 DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceGLX
);
83 // A surface used to render to an offscreen pbuffer.
84 class GL_EXPORT PbufferGLSurfaceGLX
: public GLSurfaceGLX
{
86 explicit PbufferGLSurfaceGLX(const gfx::Size
& size
);
88 // Implement GLSurfaceGLX.
89 virtual bool Initialize() OVERRIDE
;
90 virtual void Destroy() OVERRIDE
;
91 virtual bool IsOffscreen() OVERRIDE
;
92 virtual bool SwapBuffers() OVERRIDE
;
93 virtual gfx::Size
GetSize() OVERRIDE
;
94 virtual void* GetHandle() OVERRIDE
;
95 virtual void* GetConfig() OVERRIDE
;
98 virtual ~PbufferGLSurfaceGLX();
105 DISALLOW_COPY_AND_ASSIGN(PbufferGLSurfaceGLX
);
110 #endif // UI_GL_GL_SURFACE_GLX_H_