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 class Config; 32 class Image; 33 34 struct Current 35 { 36 EGLint error; 37 EGLenum API; 38 Context *context; 39 Surface *drawSurface; 40 Surface *readSurface; 41 }; 42 43 void detachThread(); 44 45 void setCurrentError(EGLint error); 46 EGLint getCurrentError(); 47 48 void setCurrentAPI(EGLenum API); 49 EGLenum getCurrentAPI(); 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 79 extern LibGLES_CM libGLES_CM; 80 extern LibGLESv2 libGLESv2; 81 82 #endif // LIBEGL_MAIN_H_ 83