13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _TCUEGL_HPP 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _TCUEGL_HPP 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program Tester Core 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ---------------------------------------- 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Legacy EGL utilities 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluDefs.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuPixelFormat.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluHeaderWrapper.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector> 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <string> 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define TCU_CHECK_EGL() EGLU_CHECK() 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define TCU_CHECK_EGL_MSG(MSG) EGLU_CHECK_MSG(MSG) 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define TCU_CHECK_EGL_CALL(CALL) EGLU_CHECK_CALL(CALL) 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace eglu 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ConfigInfo; 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace tcu 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief EGL utilities 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace egl 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Surface; 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Display 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Display (EGLDisplay display, EGLint majorVersion, EGLint minorVersion); 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Display (EGLNativeDisplayType nativeDisplay); 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~Display (void); 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void getConfigs (std::vector<EGLConfig>& configs) const; 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void chooseConfig (const EGLint* attributeList, std::vector<EGLConfig>& configs) const; 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint getConfigAttrib (EGLConfig config, EGLint attribute) const; 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void describeConfig (EGLConfig config, tcu::PixelFormat& pixelFormat) const; 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void describeConfig (EGLConfig config, eglu::ConfigInfo& info) const; 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLDisplay getEGLDisplay (void) const { return m_display; } 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint getEGLMajorVersion (void) const { return m_version[0]; } 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint getEGLMinorVersion (void) const { return m_version[1]; } 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglu::Version getVersion (void) const { return eglu::Version(m_version[0], m_version[1]); } 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void getString (EGLint name, std::string& dst) const; 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void getExtensions (std::vector<std::string>& dst) const; 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string getString (EGLint name) const { std::string str; getString(name, str); return str; } 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Display (const Display&); // not allowed 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Display& operator= (const Display&); // not allowed 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLDisplay m_display; 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint m_version[2]; 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Surface 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~Surface (void) {} 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLSurface getEGLSurface (void) const { return m_surface; } 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Display& getDisplay (void) const { return m_display; } 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint getAttribute (EGLint attribute) const; 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void setAttribute (EGLint attribute, EGLint value); 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getWidth (void) const; 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getHeight (void) const; 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void getSize (int& width, int& height) const; 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Surface (Display& display) : m_display(display), m_surface(EGL_NO_SURFACE) {} 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Surface (const Surface&); // not allowed 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Surface& operator= (const Surface&); // not allowed 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Display& m_display; 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLSurface m_surface; 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass WindowSurface : public Surface 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry WindowSurface (Display& display, EGLSurface windowSurface); 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry WindowSurface (Display& display, EGLConfig config, EGLNativeWindowType nativeWindow, const EGLint* attribList); 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~WindowSurface (void); 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void swapBuffers (void); 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass PixmapSurface : public Surface 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PixmapSurface (Display& display, EGLSurface surface); 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PixmapSurface (Display& display, EGLConfig config, EGLNativePixmapType nativePixmap, const EGLint* attribList); 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~PixmapSurface (void); 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass PbufferSurface : public Surface 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PbufferSurface (Display& display, EGLConfig config, const EGLint* attribList); 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~PbufferSurface (void); 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Context 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context (const Display& display, EGLConfig config, const EGLint* attribList, EGLenum api); 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Context (void); 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLenum getAPI (void) const { return m_api; } 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLContext getEGLContext (void) const { return m_context; } 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLConfig getConfig (void) const { return m_config; } 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void makeCurrent (const Surface& draw, const Surface& read); 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context (const Context&); // not allowed 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context& operator= (const Context&); // not allowed 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const Display& m_display; 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLConfig m_config; 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLenum m_api; 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLContext m_context; 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // egl 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // tcu 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _TCUEGL_HPP 162