Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 1 | // Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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 |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 8 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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. |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 14 | |
| 15 | // main.h: Management of thread-local data. |
| 16 | |
| 17 | #ifndef LIBEGL_MAIN_H_ |
| 18 | #define LIBEGL_MAIN_H_ |
| 19 | |
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 20 | #include "libGLES_CM/libGLES_CM.hpp" |
| 21 | #include "libGLESv2/libGLESv2.hpp" |
| 22 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 23 | #include <EGL/egl.h> |
| 24 | #include <EGL/eglext.h> |
| 25 | |
| 26 | namespace egl |
| 27 | { |
Nicolas Capens | 9cc8c96 | 2015-04-02 13:18:21 -0400 | [diff] [blame] | 28 | class Display; |
| 29 | class Context; |
| 30 | class Surface; |
Nicolas Capens | 31c07a3 | 2017-06-13 23:44:13 -0400 | [diff] [blame] | 31 | class Config; |
| 32 | class Image; |
Nicolas Capens | 9cc8c96 | 2015-04-02 13:18:21 -0400 | [diff] [blame] | 33 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 34 | struct Current |
| 35 | { |
| 36 | EGLint error; |
| 37 | EGLenum API; |
Nicolas Capens | 9cc8c96 | 2015-04-02 13:18:21 -0400 | [diff] [blame] | 38 | Context *context; |
| 39 | Surface *drawSurface; |
| 40 | Surface *readSurface; |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 41 | }; |
| 42 | |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 43 | void detachThread(); |
| 44 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 45 | void setCurrentError(EGLint error); |
| 46 | EGLint getCurrentError(); |
| 47 | |
| 48 | void setCurrentAPI(EGLenum API); |
| 49 | EGLenum getCurrentAPI(); |
| 50 | |
Nicolas Capens | 9cc8c96 | 2015-04-02 13:18:21 -0400 | [diff] [blame] | 51 | void setCurrentContext(Context *ctx); |
| 52 | Context *getCurrentContext(); |
Nicolas Capens | 6899f6c | 2014-10-24 10:40:41 -0400 | [diff] [blame] | 53 | |
Nicolas Capens | 9cc8c96 | 2015-04-02 13:18:21 -0400 | [diff] [blame] | 54 | void setCurrentDrawSurface(Surface *surface); |
| 55 | Surface *getCurrentDrawSurface(); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 56 | |
Nicolas Capens | 9cc8c96 | 2015-04-02 13:18:21 -0400 | [diff] [blame] | 57 | void setCurrentReadSurface(Surface *surface); |
| 58 | Surface *getCurrentReadSurface(); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 59 | |
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 60 | void error(EGLint errorCode); |
Nicolas Capens | 3f1ab0c | 2016-02-08 15:13:57 -0500 | [diff] [blame] | 61 | |
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 62 | template<class T> |
| 63 | const T &error(EGLint errorCode, const T &returnValue) |
| 64 | { |
| 65 | egl::error(errorCode); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 66 | |
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 67 | return returnValue; |
| 68 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 69 | |
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 70 | template<class T> |
| 71 | const T &success(const T &returnValue) |
| 72 | { |
| 73 | egl::setCurrentError(EGL_SUCCESS); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 74 | |
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 75 | return returnValue; |
| 76 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 77 | } |
| 78 | |
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 79 | extern LibGLES_CM libGLES_CM; |
| 80 | extern LibGLESv2 libGLESv2; |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 81 | |
| 82 | #endif // LIBEGL_MAIN_H_ |