2 * Copyright (C) 2012 Igalia S.L.
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.
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.
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
23 #include "GraphicsContext3D.h"
24 #include "PlatformDisplay.h"
25 #include <wtf/Noncopyable.h>
27 #if USE(EGL) && !PLATFORM(GTK)
29 // FIXME: For now default to the GBM EGL platform, but this should really be
30 // somehow deducible from the build configuration.
32 #endif // PLATFORM(WPE)
33 #include <EGL/eglplatform.h>
34 typedef EGLNativeWindowType GLNativeWindowType;
35 #else // !USE(EGL) || PLATFORM(GTK)
36 typedef uint64_t GLNativeWindowType;
40 typedef struct _cairo_device cairo_device_t;
46 WTF_MAKE_NONCOPYABLE(GLContext); WTF_MAKE_FAST_ALLOCATED;
48 static std::unique_ptr<GLContext> createContextForWindow(GLNativeWindowType windowHandle, PlatformDisplay* = nullptr);
49 static std::unique_ptr<GLContext> createOffscreenContext(PlatformDisplay* = nullptr);
50 static std::unique_ptr<GLContext> createSharingContext(PlatformDisplay&);
51 static GLContext* current();
52 static bool isExtensionSupported(const char* extensionList, const char* extension);
54 PlatformDisplay& display() const { return m_display; }
58 virtual bool makeContextCurrent();
59 virtual void swapBuffers() = 0;
60 virtual void waitNative() = 0;
61 virtual bool canRenderToDefaultFramebuffer() = 0;
62 virtual IntSize defaultFrameBufferSize() = 0;
63 virtual void swapInterval(int) = 0;
65 virtual bool isEGLContext() const = 0;
68 virtual cairo_device_t* cairoDevice() = 0;
71 #if ENABLE(GRAPHICS_CONTEXT_3D)
72 virtual PlatformGraphicsContext3D platformContext() = 0;
77 static void addActiveContext(GLContext*);
78 static void removeActiveContext(GLContext*);
79 static void cleanupActiveContextsAtExit();
83 GLContext(PlatformDisplay&);
85 PlatformDisplay& m_display;
86 unsigned m_version { 0 };
89 } // namespace WebCore