1 #ifndef _TCUEGL_HPP 2 #define _TCUEGL_HPP 3 /*------------------------------------------------------------------------- 4 * drawElements Quality Program Tester Core 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 Legacy EGL utilities 24 *//*--------------------------------------------------------------------*/ 25 26 #include "egluDefs.hpp" 27 #include "tcuPixelFormat.hpp" 28 #include "egluHeaderWrapper.hpp" 29 30 #include <vector> 31 #include <string> 32 33 #define TCU_CHECK_EGL() EGLU_CHECK() 34 #define TCU_CHECK_EGL_MSG(MSG) EGLU_CHECK_MSG(MSG) 35 #define TCU_CHECK_EGL_CALL(CALL) EGLU_CHECK_CALL(CALL) 36 37 namespace eglu 38 { 39 class ConfigInfo; 40 } 41 42 namespace tcu 43 { 44 45 /*--------------------------------------------------------------------*//*! 46 * \brief EGL utilities 47 *//*--------------------------------------------------------------------*/ 48 namespace egl 49 { 50 51 class Surface; 52 53 class Display 54 { 55 public: 56 Display (EGLDisplay display, EGLint majorVersion, EGLint minorVersion); 57 Display (EGLNativeDisplayType nativeDisplay); 58 virtual ~Display (void); 59 60 void getConfigs (std::vector<EGLConfig>& configs) const; 61 void chooseConfig (const EGLint* attributeList, std::vector<EGLConfig>& configs) const; 62 63 EGLint getConfigAttrib (EGLConfig config, EGLint attribute) const; 64 void describeConfig (EGLConfig config, tcu::PixelFormat& pixelFormat) const; 65 void describeConfig (EGLConfig config, eglu::ConfigInfo& info) const; 66 getEGLDisplay(void) const67 EGLDisplay getEGLDisplay (void) const { return m_display; } getEGLMajorVersion(void) const68 EGLint getEGLMajorVersion (void) const { return m_version[0]; } getEGLMinorVersion(void) const69 EGLint getEGLMinorVersion (void) const { return m_version[1]; } 70 getVersion(void) const71 eglu::Version getVersion (void) const { return eglu::Version(m_version[0], m_version[1]); } 72 73 void getString (EGLint name, std::string& dst) const; 74 void getExtensions (std::vector<std::string>& dst) const; 75 getString(EGLint name) const76 std::string getString (EGLint name) const { std::string str; getString(name, str); return str; } 77 78 protected: 79 Display (const Display&); // not allowed 80 Display& operator= (const Display&); // not allowed 81 82 EGLDisplay m_display; 83 EGLint m_version[2]; 84 }; 85 86 class Surface 87 { 88 public: ~Surface(void)89 virtual ~Surface (void) {} 90 getEGLSurface(void) const91 EGLSurface getEGLSurface (void) const { return m_surface; } getDisplay(void) const92 Display& getDisplay (void) const { return m_display; } 93 94 EGLint getAttribute (EGLint attribute) const; 95 void setAttribute (EGLint attribute, EGLint value); 96 97 int getWidth (void) const; 98 int getHeight (void) const; 99 void getSize (int& width, int& height) const; 100 101 protected: Surface(Display & display)102 Surface (Display& display) : m_display(display), m_surface(EGL_NO_SURFACE) {} 103 104 Surface (const Surface&); // not allowed 105 Surface& operator= (const Surface&); // not allowed 106 107 Display& m_display; 108 EGLSurface m_surface; 109 }; 110 111 class WindowSurface : public Surface 112 { 113 public: 114 WindowSurface (Display& display, EGLSurface windowSurface); 115 WindowSurface (Display& display, EGLConfig config, EGLNativeWindowType nativeWindow, const EGLint* attribList); 116 virtual ~WindowSurface (void); 117 118 void swapBuffers (void); 119 }; 120 121 class PixmapSurface : public Surface 122 { 123 public: 124 PixmapSurface (Display& display, EGLSurface surface); 125 PixmapSurface (Display& display, EGLConfig config, EGLNativePixmapType nativePixmap, const EGLint* attribList); 126 virtual ~PixmapSurface (void); 127 }; 128 129 class PbufferSurface : public Surface 130 { 131 public: 132 PbufferSurface (Display& display, EGLConfig config, const EGLint* attribList); 133 virtual ~PbufferSurface (void); 134 }; 135 136 class Context 137 { 138 public: 139 Context (const Display& display, EGLConfig config, const EGLint* attribList, EGLenum api); 140 ~Context (void); 141 getAPI(void) const142 EGLenum getAPI (void) const { return m_api; } getEGLContext(void) const143 EGLContext getEGLContext (void) const { return m_context; } getConfig(void) const144 EGLConfig getConfig (void) const { return m_config; } 145 146 void makeCurrent (const Surface& draw, const Surface& read); 147 148 protected: 149 Context (const Context&); // not allowed 150 Context& operator= (const Context&); // not allowed 151 152 const Display& m_display; 153 EGLConfig m_config; 154 EGLenum m_api; 155 EGLContext m_context; 156 }; 157 158 } // egl 159 } // tcu 160 161 #endif // _TCUEGL_HPP 162