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 "eglwDefs.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_) {}
67 class WindowDestroyedError : public tcu::ResourceError
70 WindowDestroyedError (const std::string& message) : tcu::ResourceError(message) {}
78 CAPABILITY_CREATE_SURFACE_LEGACY = (1<<0), //!< EGL surface can be created with eglCreateWindowSurface()
79 CAPABILITY_CREATE_SURFACE_PLATFORM = (1<<1), //!< EGL surface can be created with eglCreatePlatformWindowSurface()
80 CAPABILITY_GET_SURFACE_SIZE = (1<<2),
81 CAPABILITY_SET_SURFACE_SIZE = (1<<3),
82 CAPABILITY_GET_SCREEN_SIZE = (1<<4),
83 CAPABILITY_READ_SCREEN_PIXELS = (1<<5),
84 CAPABILITY_CHANGE_VISIBILITY = (1<<6)
87 virtual ~NativeWindow (void) {}
89 //! Return EGLNativeWindowType that can be used with eglCreateWindowSurface(). Default implementation throws tcu::NotSupportedError().
90 virtual eglw::EGLNativeWindowType getLegacyNative (void);
92 //! Return native pointer that can be used with eglCreatePlatformWindowSurface(). Default implementation throws tcu::NotSupportedError().
93 virtual void* getPlatformNative (void);
95 // Process window events. Defaults to dummy implementation, that does nothing.
96 virtual void processEvents (void) {}
98 // Get current size of window's logical surface. Default implementation throws tcu::NotSupportedError()
99 virtual tcu::IVec2 getSurfaceSize (void) const;
101 // Set the size of the window's logical surface. Default implementation throws tcu::NotSupportedError()
102 virtual void setSurfaceSize (tcu::IVec2 size);
104 // Get the size of the window in screen pixels. Default implementation throws tcu::NotSupportedError()
105 virtual tcu::IVec2 getScreenSize (void) const;
107 // Read screen (visible) pixels from window. Default implementation throws tcu::NotSupportedError()
108 virtual void readScreenPixels (tcu::TextureLevel* dst) const;
110 // Change window visibility. Default throws tcu::NotSupportedError().
111 virtual void setVisibility (WindowParams::Visibility visibility);
113 Capability getCapabilities (void) const { return m_capabilities; }
116 NativeWindow (Capability capabilities);
119 NativeWindow (const NativeWindow&);
120 NativeWindow& operator= (const NativeWindow&);
122 const Capability m_capabilities;
125 class NativeWindowFactory : public tcu::FactoryBase
128 virtual ~NativeWindowFactory (void);
130 //! Create generic NativeWindow
131 virtual NativeWindow* createWindow (NativeDisplay* nativeDisplay, const WindowParams& params) const = 0;
133 //! Create NativeWindow that matches given config. Defaults to generic createWindow().
134 virtual NativeWindow* createWindow (NativeDisplay* nativeDisplay, eglw::EGLDisplay display, eglw::EGLConfig config, const eglw::EGLAttrib* attribList, const WindowParams& params) const;
136 NativeWindow::Capability getCapabilities (void) const { return m_capabilities; }
139 NativeWindowFactory (const std::string& name, const std::string& description, NativeWindow::Capability capabilities);
142 NativeWindowFactory (const NativeWindowFactory&);
143 NativeWindowFactory& operator= (const NativeWindowFactory&);
145 const NativeWindow::Capability m_capabilities;
148 typedef tcu::FactoryRegistry<NativeWindowFactory> NativeWindowFactoryRegistry;
152 #endif // _EGLUNATIVEWINDOW_HPP