xref: /aosp_15_r20/external/deqp/framework/platform/nullws/tcuNullWSPlatform.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 /*-------------------------------------------------------------------------
2  * OpenGL Conformance Test Suite
3  * -----------------------------
4  *
5  * Copyright (c) 2016 Google Inc.
6  * Copyright (c) 2016 The Khronos Group Inc.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  *//*!
21  * \file
22  * \brief
23  *//*--------------------------------------------------------------------*/
24 
25 #include "tcuNullWSPlatform.hpp"
26 #include "eglwEnums.hpp"
27 #include "eglwLibrary.hpp"
28 #include "egluGLContextFactory.hpp"
29 
30 namespace tcu
31 {
32 namespace nullws
33 {
34 
35 class Window : public eglu::NativeWindow
36 {
37 public:
38     static const Capability CAPABILITIES = CAPABILITY_CREATE_SURFACE_LEGACY;
39 
Window(eglu::NativeDisplay * nativeDisplay,const eglu::WindowParams & params)40     Window(eglu::NativeDisplay *nativeDisplay, const eglu::WindowParams &params) : NativeWindow(CAPABILITIES)
41     {
42     }
43 
getLegacyNative()44     eglw::EGLNativeWindowType getLegacyNative()
45     {
46         return DE_NULL;
47     }
48 };
49 
50 class WindowFactory : public eglu::NativeWindowFactory
51 {
52 public:
WindowFactory()53     WindowFactory() : NativeWindowFactory("nullws", "NullWS Window", Window::CAPABILITIES)
54     {
55     }
56 
createWindow(eglu::NativeDisplay * nativeDisplay,const eglu::WindowParams & params) const57     eglu::NativeWindow *createWindow(eglu::NativeDisplay *nativeDisplay, const eglu::WindowParams &params) const
58     {
59         return new Window(nativeDisplay, params);
60     }
61 };
62 
63 class Pixmap : public eglu::NativePixmap
64 {
65 public:
66     static const Capability CAPABILITIES = CAPABILITY_CREATE_SURFACE_LEGACY;
67 
Pixmap()68     Pixmap() : NativePixmap(CAPABILITIES)
69     {
70     }
71 
getLegacyNative()72     eglw::EGLNativePixmapType getLegacyNative()
73     {
74         return DE_NULL;
75     }
76 };
77 
78 class PixmapFactory : public eglu::NativePixmapFactory
79 {
80 public:
PixmapFactory()81     PixmapFactory() : NativePixmapFactory("nullws", "NullWS Pixmap", Pixmap::CAPABILITIES)
82     {
83     }
84 
createPixmap(eglu::NativeDisplay *,int,int) const85     eglu::NativePixmap *createPixmap(eglu::NativeDisplay *, int, int) const
86     {
87         return new Pixmap();
88     }
89 };
90 
91 class Display : public eglu::NativeDisplay
92 {
93 public:
94     static const Capability CAPABILITIES = CAPABILITY_GET_DISPLAY_LEGACY;
95 
Display()96     Display() : eglu::NativeDisplay(CAPABILITIES)
97     {
98     }
99 
getLegacyNative()100     eglw::EGLNativeDisplayType getLegacyNative()
101     {
102         return EGL_DEFAULT_DISPLAY;
103     }
104 
getLibrary() const105     const eglw::Library &getLibrary() const
106     {
107         return m_library;
108     }
109 
110 private:
111     eglw::DefaultLibrary m_library;
112 };
113 
114 class DisplayFactory : public eglu::NativeDisplayFactory
115 {
116 public:
DisplayFactory()117     DisplayFactory() : eglu::NativeDisplayFactory("nullws", "NullWS Display", Display::CAPABILITIES)
118     {
119         m_nativeWindowRegistry.registerFactory(new WindowFactory());
120         m_nativePixmapRegistry.registerFactory(new PixmapFactory());
121     }
122 
createDisplay(const eglw::EGLAttrib * attribList=DE_NULL) const123     eglu::NativeDisplay *createDisplay(const eglw::EGLAttrib *attribList = DE_NULL) const
124     {
125         return new Display();
126     }
127 };
128 
Platform()129 Platform::Platform()
130 {
131     m_nativeDisplayFactoryRegistry.registerFactory(new DisplayFactory());
132     m_contextFactoryRegistry.registerFactory(new eglu::GLContextFactory(m_nativeDisplayFactoryRegistry));
133 }
134 
~Platform()135 Platform::~Platform()
136 {
137 }
138 
139 } // namespace nullws
140 } // namespace tcu
141 
createPlatform()142 tcu::Platform *createPlatform()
143 {
144     return new tcu::nullws::Platform();
145 }
146