xref: /aosp_15_r20/external/deqp/framework/egl/egluNativePixmap.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 #ifndef _EGLUNATIVEPIXMAP_HPP
2 #define _EGLUNATIVEPIXMAP_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program Tester Core
5  * ----------------------------------------
6  *
7  * Copyright 2014 The Android Open Source Project
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief EGL native pixmap abstraction
24  *//*--------------------------------------------------------------------*/
25 
26 #include "tcuDefs.hpp"
27 #include "tcuFactoryRegistry.hpp"
28 #include "eglwDefs.hpp"
29 #include "tcuVector.hpp"
30 
31 namespace tcu
32 {
33 class TextureLevel;
34 }
35 
36 namespace eglu
37 {
38 
39 class NativeDisplay;
40 
41 class NativePixmap
42 {
43 public:
44     enum Capability
45     {
46         CAPABILITY_CREATE_SURFACE_LEGACY = (1 << 0), //!< EGL surface can be created with eglCreatePixmapSurface()
47         CAPABILITY_CREATE_SURFACE_PLATFORM =
48             (1 << 1), //!< EGL surface can be created with eglCreatePlatformPixmapSurface()
49         CAPABILITY_CREATE_SURFACE_PLATFORM_EXTENSION =
50             (1 << 2), //!< EGL surface can be created with eglCreatePlatformPixmapSurfaceEXT()
51         CAPABILITY_READ_PIXELS = (1 << 3)
52     };
53 
~NativePixmap(void)54     virtual ~NativePixmap(void)
55     {
56     }
57 
58     //! Return EGLNativePixmapType that can be used with eglCreatePixmapSurface(). Default implementation throws tcu::NotSupportedError().
59     virtual eglw::EGLNativePixmapType getLegacyNative(void);
60 
61     //! Return native pointer that can be used with eglCreatePlatformPixmapSurface(). Default implementation throws tcu::NotSupportedError().
62     virtual void *getPlatformNative(void);
63 
64     //! Return native pointer that can be used with eglCreatePlatformPixmapSurfaceEXT(). Default implementation throws tcu::NotSupportedError().
65     virtual void *getPlatformExtension(void);
66 
67     // Read pixels from pixmap. Default implementation throws tcu::NotSupportedError()
68     virtual void readPixels(tcu::TextureLevel *dst);
69 
70     // These values are initialized in constructor.
getCapabilities(void) const71     Capability getCapabilities(void) const
72     {
73         return m_capabilities;
74     }
75 
76 protected:
77     NativePixmap(Capability capabilities);
78 
79 private:
80     NativePixmap(const NativePixmap &);
81     NativePixmap &operator=(const NativePixmap &);
82 
83     const Capability m_capabilities;
84 };
85 
86 class NativePixmapFactory : public tcu::FactoryBase
87 {
88 public:
89     virtual ~NativePixmapFactory(void);
90 
91     //! Create generic pixmap.
92     virtual NativePixmap *createPixmap(NativeDisplay *nativeDisplay, int width, int height) const = 0;
93 
94     //! Create pixmap that matches given EGL config. Defaults to generic createPixmap().
95     virtual NativePixmap *createPixmap(NativeDisplay *nativeDisplay, eglw::EGLDisplay display, eglw::EGLConfig config,
96                                        const eglw::EGLAttrib *attribList, int width, int height) const;
97 
getCapabilities(void) const98     NativePixmap::Capability getCapabilities(void) const
99     {
100         return m_capabilities;
101     }
102 
103 protected:
104     NativePixmapFactory(const std::string &name, const std::string &description, NativePixmap::Capability capabilities);
105 
106 private:
107     NativePixmapFactory(const NativePixmapFactory &);
108     NativePixmapFactory &operator=(const NativePixmapFactory &);
109 
110     const NativePixmap::Capability m_capabilities;
111 };
112 
113 typedef tcu::FactoryRegistry<NativePixmapFactory> NativePixmapFactoryRegistry;
114 
115 } // namespace eglu
116 
117 #endif // _EGLUNATIVEPIXMAP_HPP
118