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 "libGLESv2/libGLESv2.hpp" 21 22 #include <EGL/egl.h> 23 #include <EGL/eglext.h> 24 25 namespace egl 26 { 27 class Display; 28 class Context; 29 class Surface; 30 class Config; 31 class Image; 32 33 struct Current 34 { 35 EGLint error; 36 EGLenum API; 37 Context *context; 38 Surface *drawSurface; 39 Surface *readSurface; 40 }; 41 42 void detachThread(); 43 44 void setCurrentError(EGLint error); 45 EGLint getCurrentError(); 46 47 void setCurrentAPI(EGLenum API); 48 EGLenum getCurrentAPI(); 49 50 void setCurrentContext(Context *ctx); 51 Context *getCurrentContext(); 52 53 void setCurrentDrawSurface(Surface *surface); 54 Surface *getCurrentDrawSurface(); 55 56 void setCurrentReadSurface(Surface *surface); 57 Surface *getCurrentReadSurface(); 58 59 void error(EGLint errorCode); 60 61 template<class T> error(EGLint errorCode,const T & returnValue)62 const T &error(EGLint errorCode, const T &returnValue) 63 { 64 egl::error(errorCode); 65 66 return returnValue; 67 } 68 69 template<class T> success(const T & returnValue)70 const T &success(const T &returnValue) 71 { 72 egl::setCurrentError(EGL_SUCCESS); 73 74 return returnValue; 75 } 76 } 77 78 extern LibGLESv2 libGLESv2; 79 80 #endif // LIBEGL_MAIN_H_ 81