1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // main.h: Management of thread-local data. 16 17 #ifndef LIBEGL_MAIN_H_ 18 #define LIBEGL_MAIN_H_ 19 20 #include "libGLES_CM/libGLES_CM.hpp" 21 #include "libGLESv2/libGLESv2.hpp" 22 23 #include <EGL/egl.h> 24 #include <EGL/eglext.h> 25 26 namespace egl 27 { 28 class Display; 29 class Context; 30 class Surface; 31 32 struct Current 33 { 34 EGLint error; 35 EGLenum API; 36 EGLDisplay display; 37 Context *context; 38 Surface *drawSurface; 39 Surface *readSurface; 40 }; 41 42 void setCurrentError(EGLint error); 43 EGLint getCurrentError(); 44 45 void setCurrentAPI(EGLenum API); 46 EGLenum getCurrentAPI(); 47 48 void setCurrentDisplay(EGLDisplay dpy); 49 EGLDisplay getCurrentDisplay(); 50 51 void setCurrentContext(Context *ctx); 52 Context *getCurrentContext(); 53 54 void setCurrentDrawSurface(Surface *surface); 55 Surface *getCurrentDrawSurface(); 56 57 void setCurrentReadSurface(Surface *surface); 58 Surface *getCurrentReadSurface(); 59 60 void error(EGLint errorCode); 61 62 template<class T> error(EGLint errorCode,const T & returnValue)63 const T &error(EGLint errorCode, const T &returnValue) 64 { 65 egl::error(errorCode); 66 67 return returnValue; 68 } 69 70 template<class T> success(const T & returnValue)71 const T &success(const T &returnValue) 72 { 73 egl::setCurrentError(EGL_SUCCESS); 74 75 return returnValue; 76 } 77 78 class Config; 79 class Surface; 80 class Display; 81 class Context; 82 class Image; 83 } 84 85 extern LibGLES_CM libGLES_CM; 86 extern LibGLESv2 libGLESv2; 87 88 #endif // LIBEGL_MAIN_H_ 89