1 | /* |
2 | * Copyright (C) 2012 Igalia S.L. |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Lesser General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Lesser General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Lesser General Public |
15 | * License along with this library; if not, write to the Free |
16 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | * Boston, MA 02110-1301 USA |
18 | */ |
19 | |
20 | #pragma once |
21 | |
22 | #if USE(GLX) |
23 | |
24 | #include "GLContext.h" |
25 | #include "XUniquePtr.h" |
26 | #include "XUniqueResource.h" |
27 | |
28 | typedef unsigned char GLubyte; |
29 | typedef unsigned long Window; |
30 | typedef void* ContextKeyType; |
31 | typedef struct _XDisplay Display; |
32 | |
33 | namespace WebCore { |
34 | |
35 | class GLContextGLX final : public GLContext { |
36 | WTF_MAKE_NONCOPYABLE(GLContextGLX); |
37 | public: |
38 | static std::unique_ptr<GLContextGLX> createContext(GLNativeWindowType, PlatformDisplay&); |
39 | static std::unique_ptr<GLContextGLX> createSharingContext(PlatformDisplay&); |
40 | |
41 | virtual ~GLContextGLX(); |
42 | |
43 | private: |
44 | bool makeContextCurrent() override; |
45 | void swapBuffers() override; |
46 | void waitNative() override; |
47 | bool canRenderToDefaultFramebuffer() override; |
48 | IntSize defaultFrameBufferSize() override; |
49 | void swapInterval(int) override; |
50 | cairo_device_t* cairoDevice() override; |
51 | bool isEGLContext() const override { return false; } |
52 | |
53 | #if ENABLE(GRAPHICS_CONTEXT_3D) |
54 | PlatformGraphicsContext3D platformContext() override; |
55 | #endif |
56 | |
57 | GLContextGLX(PlatformDisplay&, XUniqueGLXContext&&, GLNativeWindowType); |
58 | GLContextGLX(PlatformDisplay&, XUniqueGLXContext&&, XUniqueGLXPbuffer&&); |
59 | GLContextGLX(PlatformDisplay&, XUniqueGLXContext&&, XUniquePixmap&&, XUniqueGLXPixmap&&); |
60 | |
61 | static std::unique_ptr<GLContextGLX> createWindowContext(GLNativeWindowType, PlatformDisplay&, GLXContext sharingContext = nullptr); |
62 | static std::unique_ptr<GLContextGLX> createPbufferContext(PlatformDisplay&, GLXContext sharingContext = nullptr); |
63 | static std::unique_ptr<GLContextGLX> createPixmapContext(PlatformDisplay&, GLXContext sharingContext = nullptr); |
64 | |
65 | Display* m_x11Display { nullptr }; |
66 | XUniqueGLXContext m_context; |
67 | Window m_window { 0 }; |
68 | XUniqueGLXPbuffer m_pbuffer; |
69 | XUniquePixmap m_pixmap; |
70 | XUniqueGLXPixmap m_glxPixmap; |
71 | cairo_device_t* m_cairoDevice { nullptr }; |
72 | }; |
73 | |
74 | } // namespace WebCore |
75 | |
76 | #endif // USE(GLX) |
77 | |
78 | |