1 #ifndef _EGLUNATIVEWINDOW_HPP
2 #define _EGLUNATIVEWINDOW_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program Tester Core
5 * ----------------------------------------
7 * Copyright 2014 The Android Open Source Project
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 * \brief EGL native window abstraction
24 *//*--------------------------------------------------------------------*/
26 #include "tcuDefs.hpp"
27 #include "tcuFactoryRegistry.hpp"
28 #include "egluHeaderWrapper.hpp"
29 #include "tcuVector.hpp"
46 VISIBILITY_HIDDEN = 0,
48 VISIBILITY_FULLSCREEN,
59 int width; //!< Positive size, or SIZE_DONT_CARE
60 int height; //!< Positive size, or SIZE_DONT_CARE
61 Visibility visibility; //!< Visibility for window
63 WindowParams (void) : width(SIZE_DONT_CARE), height(SIZE_DONT_CARE), visibility(VISIBILITY_DONT_CARE) {}
64 WindowParams (int width_, int height_, Visibility visibility_) : width(width_), height(height_), visibility(visibility_) {}
72 CAPABILITY_CREATE_SURFACE_LEGACY = (1<<0), //!< EGL surface can be created with eglCreateWindowSurface()
73 CAPABILITY_CREATE_SURFACE_PLATFORM = (1<<1), //!< EGL surface can be created with eglCreatePlatformWindowSurface()
74 CAPABILITY_GET_SURFACE_SIZE = (1<<2),
75 CAPABILITY_SET_SURFACE_SIZE = (1<<3),
76 CAPABILITY_GET_SCREEN_SIZE = (1<<4),
77 CAPABILITY_READ_SCREEN_PIXELS = (1<<5),
78 CAPABILITY_CHANGE_VISIBILITY = (1<<6)
81 virtual ~NativeWindow (void) {}
83 //! Return EGLNativeWindowType that can be used with eglCreateWindowSurface(). Default implementation throws tcu::NotSupportedError().
84 virtual EGLNativeWindowType getLegacyNative (void);
86 //! Return native pointer that can be used with eglCreatePlatformWindowSurface(). Default implementation throws tcu::NotSupportedError().
87 virtual void* getPlatformNative (void);
89 // Process window events. Defaults to dummy implementation, that does nothing.
90 virtual void processEvents (void) {}
92 // Get current size of window's logical surface. Default implementation throws tcu::NotSupportedError()
93 virtual tcu::IVec2 getSurfaceSize (void) const;
95 // Set the size of the window's logical surface. Default implementation throws tcu::NotSupportedError()
96 virtual void setSurfaceSize (tcu::IVec2 size);
98 // Get the size of the window in screen pixels. Default implementation throws tcu::NotSupportedError()
99 virtual tcu::IVec2 getScreenSize (void) const;
101 // Read screen (visible) pixels from window. Default implementation throws tcu::NotSupportedError()
102 virtual void readScreenPixels (tcu::TextureLevel* dst) const;
104 // Change window visibility. Default throws tcu::NotSupportedError().
105 virtual void setVisibility (WindowParams::Visibility visibility);
107 Capability getCapabilities (void) const { return m_capabilities; }
110 NativeWindow (Capability capabilities);
113 NativeWindow (const NativeWindow&);
114 NativeWindow& operator= (const NativeWindow&);
116 const Capability m_capabilities;
119 class NativeWindowFactory : public tcu::FactoryBase
122 virtual ~NativeWindowFactory (void);
124 //! Create generic NativeWindow
125 virtual NativeWindow* createWindow (NativeDisplay* nativeDisplay, const WindowParams& params) const = 0;
127 //! Create NativeWindow that matches given config. Defaults to generic createWindow().
128 virtual NativeWindow* createWindow (NativeDisplay* nativeDisplay, EGLDisplay display, EGLConfig config, const EGLAttrib* attribList, const WindowParams& params) const;
130 NativeWindow::Capability getCapabilities (void) const { return m_capabilities; }
133 NativeWindowFactory (const std::string& name, const std::string& description, NativeWindow::Capability capabilities);
136 NativeWindowFactory (const NativeWindowFactory&);
137 NativeWindowFactory& operator= (const NativeWindowFactory&);
139 const NativeWindow::Capability m_capabilities;
142 typedef tcu::FactoryRegistry<NativeWindowFactory> NativeWindowFactoryRegistry;
146 #endif // _EGLUNATIVEWINDOW_HPP