Merge pull request #26166 from ksooo/improve-plugin-ctx-menus
[xbmc.git] / xbmc / utils / EGLImage.h
blob5e861555711ee5e3e276d45c5b3a8b02e4df49ed
1 /*
2 * Copyright (C) 2017-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "system_egl.h"
13 #include <array>
15 #include <EGL/eglext.h>
16 #include <drm_fourcc.h>
18 #include "system_gl.h"
20 class CEGLImage
22 public:
23 static const int MAX_NUM_PLANES{3};
25 struct EglPlane
27 int fd{0};
28 int offset{0};
29 int pitch{0};
30 uint64_t modifier{DRM_FORMAT_MOD_INVALID};
33 struct EglAttrs
35 int width{0};
36 int height{0};
37 uint32_t format{0};
38 int colorSpace{0};
39 int colorRange{0};
40 std::array<EglPlane, MAX_NUM_PLANES> planes;
43 explicit CEGLImage(EGLDisplay display);
45 CEGLImage(CEGLImage const& other) = delete;
46 CEGLImage& operator=(CEGLImage const& other) = delete;
48 bool CreateImage(EglAttrs imageAttrs);
49 void UploadImage(GLenum textureTarget);
50 void DestroyImage();
52 #if defined(EGL_EXT_image_dma_buf_import_modifiers)
53 bool SupportsFormatAndModifier(uint32_t format, uint64_t modifier);
55 private:
56 bool SupportsFormat(uint32_t format);
57 #else
58 private:
59 #endif
60 EGLDisplay m_display{nullptr};
61 EGLImageKHR m_image{nullptr};
63 PFNEGLCREATEIMAGEKHRPROC m_eglCreateImageKHR{nullptr};
64 PFNEGLDESTROYIMAGEKHRPROC m_eglDestroyImageKHR{nullptr};
65 PFNGLEGLIMAGETARGETTEXTURE2DOESPROC m_glEGLImageTargetTexture2DOES{nullptr};