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 37namespace eglu 38{ 39class ConfigInfo; 40} 41 42namespace tcu 43{ 44 45/*--------------------------------------------------------------------*//*! 46 * \brief EGL utilities 47 *//*--------------------------------------------------------------------*/ 48namespace egl 49{ 50 51class Surface; 52 53class Display 54{ 55public: 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 67 EGLDisplay getEGLDisplay (void) const { return m_display; } 68 EGLint getEGLMajorVersion (void) const { return m_version[0]; } 69 EGLint getEGLMinorVersion (void) const { return m_version[1]; } 70 71 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 76 std::string getString (EGLint name) const { std::string str; getString(name, str); return str; } 77 78protected: 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 86class Surface 87{ 88public: 89 virtual ~Surface (void) {} 90 91 EGLSurface getEGLSurface (void) const { return m_surface; } 92 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 101protected: 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 111class WindowSurface : public Surface 112{ 113public: 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 121class PixmapSurface : public Surface 122{ 123public: 124 PixmapSurface (Display& display, EGLSurface surface); 125 PixmapSurface (Display& display, EGLConfig config, EGLNativePixmapType nativePixmap, const EGLint* attribList); 126 virtual ~PixmapSurface (void); 127}; 128 129class PbufferSurface : public Surface 130{ 131public: 132 PbufferSurface (Display& display, EGLConfig config, const EGLint* attribList); 133 virtual ~PbufferSurface (void); 134}; 135 136class Context 137{ 138public: 139 Context (const Display& display, EGLConfig config, const EGLint* attribList, EGLenum api); 140 ~Context (void); 141 142 EGLenum getAPI (void) const { return m_api; } 143 EGLContext getEGLContext (void) const { return m_context; } 144 EGLConfig getConfig (void) const { return m_config; } 145 146 void makeCurrent (const Surface& draw, const Surface& read); 147 148protected: 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