1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
|
/*
* Copyright (C) 2015 Igalia S.L
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <wtf/Noncopyable.h>
#include <wtf/TypeCasts.h>
#include <wtf/text/WTFString.h>
#if USE(EGL)
typedef intptr_t EGLAttrib;
typedef void *EGLClientBuffer;
typedef void *EGLContext;
typedef void *EGLDisplay;
typedef void *EGLImage;
typedef unsigned EGLenum;
#if USE(GBM)
typedef void *EGLDeviceEXT;
struct gbm_device;
#endif
#endif
#if PLATFORM(GTK)
#include <wtf/glib/GRefPtr.h>
typedef struct _GdkDisplay GdkDisplay;
#endif
#if ENABLE(VIDEO) && USE(GSTREAMER_GL)
#include "GRefPtrGStreamer.h"
typedef struct _GstGLContext GstGLContext;
typedef struct _GstGLDisplay GstGLDisplay;
#endif // ENABLE(VIDEO) && USE(GSTREAMER_GL)
#if USE(LCMS)
#include "LCMSUniquePtr.h"
#endif
namespace WebCore {
class GLContext;
class PlatformDisplay {
WTF_MAKE_NONCOPYABLE(PlatformDisplay); WTF_MAKE_FAST_ALLOCATED;
public:
WEBCORE_EXPORT static PlatformDisplay& sharedDisplay();
WEBCORE_EXPORT static PlatformDisplay& sharedDisplayForCompositing();
virtual ~PlatformDisplay();
enum class Type {
#if PLATFORM(X11)
X11,
#endif
#if PLATFORM(WAYLAND)
Wayland,
#endif
#if PLATFORM(WIN)
Windows,
#endif
#if USE(WPE_RENDERER)
WPE,
#endif
#if USE(EGL)
Surfaceless,
#if USE(GBM)
GBM,
#endif
#endif
};
virtual Type type() const = 0;
#if USE(EGL)
WEBCORE_EXPORT GLContext* sharingGLContext();
void clearSharingGLContext();
#endif
#if USE(EGL)
EGLDisplay eglDisplay() const;
bool eglCheckVersion(int major, int minor) const;
struct EGLExtensions {
bool KHR_image_base { false };
bool KHR_surfaceless_context { false };
bool EXT_image_dma_buf_import { false };
bool EXT_image_dma_buf_import_modifiers { false };
bool MESA_image_dma_buf_export { false };
};
const EGLExtensions& eglExtensions() const;
EGLImage createEGLImage(EGLContext, EGLenum target, EGLClientBuffer, const Vector<EGLAttrib>&) const;
bool destroyEGLImage(EGLImage) const;
#if USE(GBM)
const String& drmDeviceFile();
const String& drmRenderNodeFile();
struct gbm_device* gbmDevice();
#endif
#if PLATFORM(GTK)
virtual EGLDisplay gtkEGLDisplay() { return nullptr; }
#endif
#if ENABLE(WEBGL)
EGLDisplay angleEGLDisplay() const;
EGLContext angleSharingGLContext();
#endif
#endif
#if ENABLE(VIDEO) && USE(GSTREAMER_GL)
GstGLDisplay* gstGLDisplay() const;
GstGLContext* gstGLContext() const;
#endif
#if USE(LCMS)
virtual cmsHPROFILE colorProfile() const;
#endif
#if USE(ATSPI)
const String& accessibilityBusAddress() const;
#endif
protected:
PlatformDisplay();
#if PLATFORM(GTK)
explicit PlatformDisplay(GdkDisplay*);
#endif
static void setSharedDisplayForCompositing(PlatformDisplay&);
#if PLATFORM(GTK)
virtual void sharedDisplayDidClose();
GRefPtr<GdkDisplay> m_sharedDisplay;
#endif
#if USE(EGL)
virtual void initializeEGLDisplay();
EGLDisplay m_eglDisplay;
bool m_eglDisplayOwned { true };
std::unique_ptr<GLContext> m_sharingGLContext;
#if USE(GBM)
std::optional<String> m_drmDeviceFile;
std::optional<String> m_drmRenderNodeFile;
#endif
#if ENABLE(WEBGL) && !PLATFORM(WIN)
std::optional<int> m_anglePlatform;
void* m_angleNativeDisplay { nullptr };
#endif
#endif
#if USE(LCMS)
mutable LCMSProfilePtr m_iccProfile;
#endif
#if USE(ATSPI)
virtual String platformAccessibilityBusAddress() const { return { }; }
mutable std::optional<String> m_accessibilityBusAddress;
#endif
private:
static std::unique_ptr<PlatformDisplay> createPlatformDisplay();
#if ENABLE(WEBGL) && !PLATFORM(WIN)
void clearANGLESharingGLContext();
#endif
#if USE(EGL)
void terminateEGLDisplay();
#if USE(GBM)
EGLDeviceEXT eglDevice();
#endif
bool m_eglDisplayInitialized { false };
int m_eglMajorVersion { 0 };
int m_eglMinorVersion { 0 };
EGLExtensions m_eglExtensions;
#if ENABLE(WEBGL) && !PLATFORM(WIN)
mutable EGLDisplay m_angleEGLDisplay { nullptr };
EGLContext m_angleSharingGLContext { nullptr };
#endif
#endif
#if ENABLE(VIDEO) && USE(GSTREAMER_GL)
bool tryEnsureGstGLContext() const;
mutable GRefPtr<GstGLDisplay> m_gstGLDisplay;
mutable GRefPtr<GstGLContext> m_gstGLContext;
#endif
};
} // namespace WebCore
#define SPECIALIZE_TYPE_TRAITS_PLATFORM_DISPLAY(ToClassName, DisplayType) \
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \
static bool isType(const WebCore::PlatformDisplay& display) { return display.type() == WebCore::PlatformDisplay::Type::DisplayType; } \
SPECIALIZE_TYPE_TRAITS_END()
|