summaryrefslogtreecommitdiffstats
path: root/src/core/ozone/gl_surface_egl_qt.h
blob: 8a799b847db52391335fd3348cc896a92276ee7a (plain)
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
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef GL_SURFACE_EGL_QT_H_
#define GL_SURFACE_EGL_QT_H_

#include "gl_surface_qt.h"
#include <EGL/egl.h>
#include <EGL/eglext.h>

namespace gl {

class GLSurfaceEGLQt: public GLSurfaceQt {
public:
    explicit GLSurfaceEGLQt(const gfx::Size& size);

    static bool InitializeOneOff();
    static bool InitializeExtensionSettingsOneOff();

    bool Initialize(GLSurfaceFormat format) override;
    void Destroy() override;
    void* GetHandle() override;
    bool Resize(const gfx::Size& size, float scale_factor,
                const gfx::ColorSpace &color_space, bool has_alpha) override;


protected:
    ~GLSurfaceEGLQt();

public:
   static bool g_egl_surfaceless_context_supported;

private:
   EGLSurface m_surfaceBuffer;
   static bool s_initialized;
};

// The following comment is cited from chromium/ui/gl/gl_surface_egl.cc:
// SurfacelessEGL is used as Offscreen surface when platform supports
// KHR_surfaceless_context and GL_OES_surfaceless_context. This would avoid the
// need to create a dummy EGLsurface in case we render to client API targets.

class GLSurfacelessQtEGL : public GLSurfaceQt {
public:
    explicit GLSurfacelessQtEGL(const gfx::Size& size);

public:
    bool Initialize(GLSurfaceFormat format) override;
    void Destroy() override;
    bool IsSurfaceless() const override;
    bool Resize(const gfx::Size& size, float scale_factor,
                const gfx::ColorSpace &color_space, bool has_alpha) override;
    EGLSurface GetHandle() override;
    void* GetShareHandle() override;
};
}

#endif