xref: /aosp_15_r20/external/deqp/modules/egl/teglImageUtil.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 #ifndef _TEGLIMAGEUTIL_HPP
2 #define _TEGLIMAGEUTIL_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program EGL Module
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 Common utilities for EGL images.
24  *//*--------------------------------------------------------------------*/
25 
26 #include "tcuDefs.hpp"
27 #include "tcuTexture.hpp"
28 
29 #include "deUniquePtr.hpp"
30 
31 #include "teglTestCase.hpp"
32 
33 #include "egluUtil.hpp"
34 #include "egluUnique.hpp"
35 
36 #include "glwDefs.hpp"
37 
38 namespace eglw
39 {
40 class Library;
41 }
42 
43 namespace deqp
44 {
45 namespace egl
46 {
47 namespace Image
48 {
49 
50 class ManagedSurface
51 {
52 public:
ManagedSurface(de::MovePtr<eglu::UniqueSurface> surface)53     ManagedSurface(de::MovePtr<eglu::UniqueSurface> surface) : m_surface(surface)
54     {
55     }
~ManagedSurface(void)56     virtual ~ManagedSurface(void)
57     {
58     }
get(void) const59     eglw::EGLSurface get(void) const
60     {
61         return **m_surface;
62     }
63 
64 private:
65     de::UniquePtr<eglu::UniqueSurface> m_surface;
66 };
67 
68 de::MovePtr<ManagedSurface> createSurface(EglTestContext &eglTestCtx, eglw::EGLDisplay display, eglw::EGLConfig config,
69                                           int width, int height);
70 
71 class ClientBuffer
72 {
73 public:
~ClientBuffer(void)74     virtual ~ClientBuffer(void)
75     {
76     }
77     virtual eglw::EGLClientBuffer get(void) const = 0;
78 };
79 
80 class ImageSource
81 {
82 public:
~ImageSource(void)83     virtual ~ImageSource(void)
84     {
85     }
86     virtual std::string getRequiredExtension(void) const                                      = 0;
87     virtual de::MovePtr<ClientBuffer> createBuffer(const eglw::Library &egl, const glw::Functions &gl,
88                                                    tcu::Texture2D *reference = DE_NULL) const = 0;
89     virtual eglw::EGLImageKHR createImage(const eglw::Library &egl, eglw::EGLDisplay dpy, eglw::EGLContext ctx,
90                                           eglw::EGLClientBuffer clientBuffer) const           = 0;
91     virtual glw::GLenum getEffectiveFormat(void) const                                        = 0;
isYUVFormatImage(void) const92     virtual bool isYUVFormatImage(void) const
93     {
94         return false;
95     };
96 };
97 
98 de::MovePtr<ImageSource> createTextureImageSource(eglw::EGLenum source, glw::GLenum internalFormat, glw::GLenum format,
99                                                   glw::GLenum type, bool useTexLevel0 = false);
100 de::MovePtr<ImageSource> createRenderbufferImageSource(glw::GLenum format);
101 de::MovePtr<ImageSource> createUnsupportedImageSource(const std::string &message, glw::GLenum format, bool isYUV);
102 
103 } // namespace Image
104 } // namespace egl
105 } // namespace deqp
106 
107 #endif // _TEGLIMAGEUTIL_HPP
108