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