kodi
EGLImage.h
1 /*
2  * Copyright (C) 2017-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "system_egl.h"
12 
13 #include <array>
14 
15 #include <EGL/eglext.h>
16 #include <drm_fourcc.h>
17 
18 #include "system_gl.h"
19 
20 class CEGLImage
21 {
22 public:
23  static const int MAX_NUM_PLANES{3};
24 
25  struct EglPlane
26  {
27  int fd{0};
28  int offset{0};
29  int pitch{0};
30  uint64_t modifier{DRM_FORMAT_MOD_INVALID};
31  };
32 
33  struct EglAttrs
34  {
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;
41  };
42 
43  explicit CEGLImage(EGLDisplay display);
44 
45  CEGLImage(CEGLImage const& other) = delete;
46  CEGLImage& operator=(CEGLImage const& other) = delete;
47 
48  bool CreateImage(EglAttrs imageAttrs);
49  void UploadImage(GLenum textureTarget);
50  void DestroyImage();
51 
52 #if defined(EGL_EXT_image_dma_buf_import_modifiers)
53  bool SupportsFormatAndModifier(uint32_t format, uint64_t modifier);
54 
55 private:
56  bool SupportsFormat(uint32_t format);
57 #else
58 private:
59 #endif
60  EGLDisplay m_display{nullptr};
61  EGLImageKHR m_image{nullptr};
62 
63  PFNEGLCREATEIMAGEKHRPROC m_eglCreateImageKHR{nullptr};
64  PFNEGLDESTROYIMAGEKHRPROC m_eglDestroyImageKHR{nullptr};
65  PFNGLEGLIMAGETARGETTEXTURE2DOESPROC m_glEGLImageTargetTexture2DOES{nullptr};
66 };
Definition: EGLImage.h:33
Definition: EGLImage.h:25
Definition: EGLImage.h:20