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) {}
~ManagedSurface(void)54 	virtual								~ManagedSurface	(void) {}
get(void) const55 	eglw::EGLSurface					get				(void) const { return **m_surface; }
56 
57 private:
58 	de::UniquePtr<eglu::UniqueSurface>	m_surface;
59 };
60 
61 de::MovePtr<ManagedSurface> createSurface (EglTestContext& eglTestCtx, eglw::EGLDisplay display, eglw::EGLConfig config, int width, int height);
62 
63 class ClientBuffer
64 {
65 public:
~ClientBuffer(void)66 	virtual							~ClientBuffer	(void) {}
67 	virtual eglw::EGLClientBuffer	get				(void) const = 0;
68 };
69 
70 class ImageSource
71 {
72 public:
~ImageSource(void)73 	virtual								~ImageSource		(void) {}
74 	virtual std::string					getRequiredExtension(void) const = 0;
75 	virtual de::MovePtr<ClientBuffer>	createBuffer		(const glw::Functions& gl, tcu::Texture2D* reference = DE_NULL) const = 0;
76 	virtual eglw::EGLImageKHR			createImage			(const eglw::Library& egl, eglw::EGLDisplay dpy, eglw::EGLContext ctx, eglw::EGLClientBuffer clientBuffer) const = 0;
77 	virtual glw::GLenum					getFormat			(void) const = 0;
78 };
79 
80 de::MovePtr<ImageSource> createTextureImageSource			(eglw::EGLenum source, glw::GLenum format, glw::GLenum type, bool useTexLevel0 = false);
81 de::MovePtr<ImageSource> createRenderbufferImageSource		(glw::GLenum format);
82 de::MovePtr<ImageSource> createUnsupportedImageSource		(const std::string& message, glw::GLenum format);
83 
84 } // Image
85 } // egl
86 } // deqp
87 
88 
89 #endif // _TEGLIMAGEUTIL_HPP
90