1*35238bceSAndroid Build Coastguard Worker #ifndef _EGLUNATIVEWINDOW_HPP 2*35238bceSAndroid Build Coastguard Worker #define _EGLUNATIVEWINDOW_HPP 3*35238bceSAndroid Build Coastguard Worker /*------------------------------------------------------------------------- 4*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program Tester Core 5*35238bceSAndroid Build Coastguard Worker * ---------------------------------------- 6*35238bceSAndroid Build Coastguard Worker * 7*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project 8*35238bceSAndroid Build Coastguard Worker * 9*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 10*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 11*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at 12*35238bceSAndroid Build Coastguard Worker * 13*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 14*35238bceSAndroid Build Coastguard Worker * 15*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 16*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 17*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 19*35238bceSAndroid Build Coastguard Worker * limitations under the License. 20*35238bceSAndroid Build Coastguard Worker * 21*35238bceSAndroid Build Coastguard Worker *//*! 22*35238bceSAndroid Build Coastguard Worker * \file 23*35238bceSAndroid Build Coastguard Worker * \brief EGL native window abstraction 24*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 25*35238bceSAndroid Build Coastguard Worker 26*35238bceSAndroid Build Coastguard Worker #include "tcuDefs.hpp" 27*35238bceSAndroid Build Coastguard Worker #include "tcuFactoryRegistry.hpp" 28*35238bceSAndroid Build Coastguard Worker #include "eglwDefs.hpp" 29*35238bceSAndroid Build Coastguard Worker #include "tcuVector.hpp" 30*35238bceSAndroid Build Coastguard Worker 31*35238bceSAndroid Build Coastguard Worker namespace tcu 32*35238bceSAndroid Build Coastguard Worker { 33*35238bceSAndroid Build Coastguard Worker class TextureLevel; 34*35238bceSAndroid Build Coastguard Worker } 35*35238bceSAndroid Build Coastguard Worker 36*35238bceSAndroid Build Coastguard Worker namespace eglu 37*35238bceSAndroid Build Coastguard Worker { 38*35238bceSAndroid Build Coastguard Worker 39*35238bceSAndroid Build Coastguard Worker class NativePixmap; 40*35238bceSAndroid Build Coastguard Worker class NativeDisplay; 41*35238bceSAndroid Build Coastguard Worker 42*35238bceSAndroid Build Coastguard Worker struct WindowParams 43*35238bceSAndroid Build Coastguard Worker { 44*35238bceSAndroid Build Coastguard Worker enum Visibility 45*35238bceSAndroid Build Coastguard Worker { 46*35238bceSAndroid Build Coastguard Worker VISIBILITY_HIDDEN = 0, 47*35238bceSAndroid Build Coastguard Worker VISIBILITY_VISIBLE, 48*35238bceSAndroid Build Coastguard Worker VISIBILITY_FULLSCREEN, 49*35238bceSAndroid Build Coastguard Worker VISIBILITY_DONT_CARE, 50*35238bceSAndroid Build Coastguard Worker 51*35238bceSAndroid Build Coastguard Worker VISIBILITY_LAST 52*35238bceSAndroid Build Coastguard Worker }; 53*35238bceSAndroid Build Coastguard Worker 54*35238bceSAndroid Build Coastguard Worker enum 55*35238bceSAndroid Build Coastguard Worker { 56*35238bceSAndroid Build Coastguard Worker SIZE_DONT_CARE = -1 57*35238bceSAndroid Build Coastguard Worker }; 58*35238bceSAndroid Build Coastguard Worker 59*35238bceSAndroid Build Coastguard Worker int width; //!< Positive size, or SIZE_DONT_CARE 60*35238bceSAndroid Build Coastguard Worker int height; //!< Positive size, or SIZE_DONT_CARE 61*35238bceSAndroid Build Coastguard Worker Visibility visibility; //!< Visibility for window 62*35238bceSAndroid Build Coastguard Worker WindowParamseglu::WindowParams63*35238bceSAndroid Build Coastguard Worker WindowParams(void) : width(SIZE_DONT_CARE), height(SIZE_DONT_CARE), visibility(VISIBILITY_DONT_CARE) 64*35238bceSAndroid Build Coastguard Worker { 65*35238bceSAndroid Build Coastguard Worker } WindowParamseglu::WindowParams66*35238bceSAndroid Build Coastguard Worker WindowParams(int width_, int height_, Visibility visibility_) 67*35238bceSAndroid Build Coastguard Worker : width(width_) 68*35238bceSAndroid Build Coastguard Worker , height(height_) 69*35238bceSAndroid Build Coastguard Worker , visibility(visibility_) 70*35238bceSAndroid Build Coastguard Worker { 71*35238bceSAndroid Build Coastguard Worker } 72*35238bceSAndroid Build Coastguard Worker }; 73*35238bceSAndroid Build Coastguard Worker 74*35238bceSAndroid Build Coastguard Worker class WindowDestroyedError : public tcu::ResourceError 75*35238bceSAndroid Build Coastguard Worker { 76*35238bceSAndroid Build Coastguard Worker public: WindowDestroyedError(const std::string & message)77*35238bceSAndroid Build Coastguard Worker WindowDestroyedError(const std::string &message) : tcu::ResourceError(message) 78*35238bceSAndroid Build Coastguard Worker { 79*35238bceSAndroid Build Coastguard Worker } 80*35238bceSAndroid Build Coastguard Worker }; 81*35238bceSAndroid Build Coastguard Worker 82*35238bceSAndroid Build Coastguard Worker class NativeWindow 83*35238bceSAndroid Build Coastguard Worker { 84*35238bceSAndroid Build Coastguard Worker public: 85*35238bceSAndroid Build Coastguard Worker enum Capability 86*35238bceSAndroid Build Coastguard Worker { 87*35238bceSAndroid Build Coastguard Worker CAPABILITY_CREATE_SURFACE_LEGACY = (1 << 0), //!< EGL surface can be created with eglCreateWindowSurface() 88*35238bceSAndroid Build Coastguard Worker CAPABILITY_CREATE_SURFACE_PLATFORM_EXTENSION = 89*35238bceSAndroid Build Coastguard Worker (1 << 1), //!< EGL surface can be created with eglCreatePlatformWindowSurfaceEXT() 90*35238bceSAndroid Build Coastguard Worker CAPABILITY_CREATE_SURFACE_PLATFORM = 91*35238bceSAndroid Build Coastguard Worker (1 << 2), //!< EGL surface can be created with eglCreatePlatformWindowSurface() 92*35238bceSAndroid Build Coastguard Worker CAPABILITY_GET_SURFACE_SIZE = (1 << 3), 93*35238bceSAndroid Build Coastguard Worker CAPABILITY_SET_SURFACE_SIZE = (1 << 4), 94*35238bceSAndroid Build Coastguard Worker CAPABILITY_GET_SCREEN_SIZE = (1 << 5), 95*35238bceSAndroid Build Coastguard Worker CAPABILITY_READ_SCREEN_PIXELS = (1 << 6), 96*35238bceSAndroid Build Coastguard Worker CAPABILITY_CHANGE_VISIBILITY = (1 << 7) 97*35238bceSAndroid Build Coastguard Worker }; 98*35238bceSAndroid Build Coastguard Worker ~NativeWindow(void)99*35238bceSAndroid Build Coastguard Worker virtual ~NativeWindow(void) 100*35238bceSAndroid Build Coastguard Worker { 101*35238bceSAndroid Build Coastguard Worker } 102*35238bceSAndroid Build Coastguard Worker 103*35238bceSAndroid Build Coastguard Worker //! Return EGLNativeWindowType that can be used with eglCreateWindowSurface(). Default implementation throws tcu::NotSupportedError(). 104*35238bceSAndroid Build Coastguard Worker virtual eglw::EGLNativeWindowType getLegacyNative(void); 105*35238bceSAndroid Build Coastguard Worker 106*35238bceSAndroid Build Coastguard Worker //! Return native pointer that can be used with eglCreatePlatformWindowSurfaceEXT(). Default implementation throws tcu::NotSupportedError(). 107*35238bceSAndroid Build Coastguard Worker virtual void *getPlatformExtension(void); 108*35238bceSAndroid Build Coastguard Worker 109*35238bceSAndroid Build Coastguard Worker //! Return native pointer that can be used with eglCreatePlatformWindowSurface(). Default implementation throws tcu::NotSupportedError(). 110*35238bceSAndroid Build Coastguard Worker virtual void *getPlatformNative(void); 111*35238bceSAndroid Build Coastguard Worker 112*35238bceSAndroid Build Coastguard Worker // Process window events. Defaults to empty implementation, that does nothing. processEvents(void)113*35238bceSAndroid Build Coastguard Worker virtual void processEvents(void) 114*35238bceSAndroid Build Coastguard Worker { 115*35238bceSAndroid Build Coastguard Worker } 116*35238bceSAndroid Build Coastguard Worker 117*35238bceSAndroid Build Coastguard Worker // Get current size of window's logical surface. Default implementation throws tcu::NotSupportedError() 118*35238bceSAndroid Build Coastguard Worker virtual tcu::IVec2 getSurfaceSize(void) const; 119*35238bceSAndroid Build Coastguard Worker 120*35238bceSAndroid Build Coastguard Worker // Set the size of the window's logical surface. Default implementation throws tcu::NotSupportedError() 121*35238bceSAndroid Build Coastguard Worker virtual void setSurfaceSize(tcu::IVec2 size); 122*35238bceSAndroid Build Coastguard Worker 123*35238bceSAndroid Build Coastguard Worker // Get the size of the window in screen pixels. Default implementation throws tcu::NotSupportedError() 124*35238bceSAndroid Build Coastguard Worker virtual tcu::IVec2 getScreenSize(void) const; 125*35238bceSAndroid Build Coastguard Worker 126*35238bceSAndroid Build Coastguard Worker // Read screen (visible) pixels from window. Default implementation throws tcu::NotSupportedError() 127*35238bceSAndroid Build Coastguard Worker virtual void readScreenPixels(tcu::TextureLevel *dst) const; 128*35238bceSAndroid Build Coastguard Worker 129*35238bceSAndroid Build Coastguard Worker // Change window visibility. Default throws tcu::NotSupportedError(). 130*35238bceSAndroid Build Coastguard Worker virtual void setVisibility(WindowParams::Visibility visibility); 131*35238bceSAndroid Build Coastguard Worker getCapabilities(void) const132*35238bceSAndroid Build Coastguard Worker Capability getCapabilities(void) const 133*35238bceSAndroid Build Coastguard Worker { 134*35238bceSAndroid Build Coastguard Worker return m_capabilities; 135*35238bceSAndroid Build Coastguard Worker } 136*35238bceSAndroid Build Coastguard Worker 137*35238bceSAndroid Build Coastguard Worker protected: 138*35238bceSAndroid Build Coastguard Worker NativeWindow(Capability capabilities); 139*35238bceSAndroid Build Coastguard Worker 140*35238bceSAndroid Build Coastguard Worker private: 141*35238bceSAndroid Build Coastguard Worker NativeWindow(const NativeWindow &); 142*35238bceSAndroid Build Coastguard Worker NativeWindow &operator=(const NativeWindow &); 143*35238bceSAndroid Build Coastguard Worker 144*35238bceSAndroid Build Coastguard Worker const Capability m_capabilities; 145*35238bceSAndroid Build Coastguard Worker }; 146*35238bceSAndroid Build Coastguard Worker 147*35238bceSAndroid Build Coastguard Worker class NativeWindowFactory : public tcu::FactoryBase 148*35238bceSAndroid Build Coastguard Worker { 149*35238bceSAndroid Build Coastguard Worker public: 150*35238bceSAndroid Build Coastguard Worker virtual ~NativeWindowFactory(void); 151*35238bceSAndroid Build Coastguard Worker 152*35238bceSAndroid Build Coastguard Worker //! Create generic NativeWindow 153*35238bceSAndroid Build Coastguard Worker virtual NativeWindow *createWindow(NativeDisplay *nativeDisplay, const WindowParams ¶ms) const = 0; 154*35238bceSAndroid Build Coastguard Worker 155*35238bceSAndroid Build Coastguard Worker //! Create NativeWindow that matches given config. Defaults to generic createWindow(). 156*35238bceSAndroid Build Coastguard Worker virtual NativeWindow *createWindow(NativeDisplay *nativeDisplay, eglw::EGLDisplay display, eglw::EGLConfig config, 157*35238bceSAndroid Build Coastguard Worker const eglw::EGLAttrib *attribList, const WindowParams ¶ms) const; 158*35238bceSAndroid Build Coastguard Worker getCapabilities(void) const159*35238bceSAndroid Build Coastguard Worker NativeWindow::Capability getCapabilities(void) const 160*35238bceSAndroid Build Coastguard Worker { 161*35238bceSAndroid Build Coastguard Worker return m_capabilities; 162*35238bceSAndroid Build Coastguard Worker } 163*35238bceSAndroid Build Coastguard Worker 164*35238bceSAndroid Build Coastguard Worker protected: 165*35238bceSAndroid Build Coastguard Worker NativeWindowFactory(const std::string &name, const std::string &description, NativeWindow::Capability capabilities); 166*35238bceSAndroid Build Coastguard Worker 167*35238bceSAndroid Build Coastguard Worker private: 168*35238bceSAndroid Build Coastguard Worker NativeWindowFactory(const NativeWindowFactory &); 169*35238bceSAndroid Build Coastguard Worker NativeWindowFactory &operator=(const NativeWindowFactory &); 170*35238bceSAndroid Build Coastguard Worker 171*35238bceSAndroid Build Coastguard Worker const NativeWindow::Capability m_capabilities; 172*35238bceSAndroid Build Coastguard Worker }; 173*35238bceSAndroid Build Coastguard Worker 174*35238bceSAndroid Build Coastguard Worker typedef tcu::FactoryRegistry<NativeWindowFactory> NativeWindowFactoryRegistry; 175*35238bceSAndroid Build Coastguard Worker 176*35238bceSAndroid Build Coastguard Worker } // namespace eglu 177*35238bceSAndroid Build Coastguard Worker 178*35238bceSAndroid Build Coastguard Worker #endif // _EGLUNATIVEWINDOW_HPP 179