blob: a2a8f440c33d45a691b951a4b3c0603d5f0f4186 [file] [log] [blame]
Nicolas Capens0bac2852016-05-07 06:09:58 -04001// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
John Bauman66b8ab22014-05-06 15:57:45 -04002//
Nicolas Capens0bac2852016-05-07 06:09:58 -04003// 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 Bauman66b8ab22014-05-06 15:57:45 -04006//
Nicolas Capens0bac2852016-05-07 06:09:58 -04007// http://www.apache.org/licenses/LICENSE-2.0
John Bauman66b8ab22014-05-06 15:57:45 -04008//
Nicolas Capens0bac2852016-05-07 06:09:58 -04009// 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 Bauman66b8ab22014-05-06 15:57:45 -040014
15// main.h: Management of thread-local data.
16
17#ifndef LIBEGL_MAIN_H_
18#define LIBEGL_MAIN_H_
19
Nicolas Capensa2308052015-04-15 16:50:21 -040020#include "libGLES_CM/libGLES_CM.hpp"
21#include "libGLESv2/libGLESv2.hpp"
22
John Bauman66b8ab22014-05-06 15:57:45 -040023#include <EGL/egl.h>
24#include <EGL/eglext.h>
25
26namespace egl
27{
Nicolas Capens9cc8c962015-04-02 13:18:21 -040028 class Display;
29 class Context;
30 class Surface;
Nicolas Capens31c07a32017-06-13 23:44:13 -040031 class Config;
32 class Image;
Nicolas Capens9cc8c962015-04-02 13:18:21 -040033
John Bauman66b8ab22014-05-06 15:57:45 -040034 struct Current
35 {
36 EGLint error;
37 EGLenum API;
Nicolas Capens9cc8c962015-04-02 13:18:21 -040038 Context *context;
39 Surface *drawSurface;
40 Surface *readSurface;
John Bauman66b8ab22014-05-06 15:57:45 -040041 };
42
Nicolas Capensaf93a422016-06-12 16:11:25 -040043 void detachThread();
44
John Bauman66b8ab22014-05-06 15:57:45 -040045 void setCurrentError(EGLint error);
46 EGLint getCurrentError();
47
48 void setCurrentAPI(EGLenum API);
49 EGLenum getCurrentAPI();
50
Nicolas Capens9cc8c962015-04-02 13:18:21 -040051 void setCurrentContext(Context *ctx);
52 Context *getCurrentContext();
Nicolas Capens6899f6c2014-10-24 10:40:41 -040053
Nicolas Capens9cc8c962015-04-02 13:18:21 -040054 void setCurrentDrawSurface(Surface *surface);
55 Surface *getCurrentDrawSurface();
John Bauman66b8ab22014-05-06 15:57:45 -040056
Nicolas Capens9cc8c962015-04-02 13:18:21 -040057 void setCurrentReadSurface(Surface *surface);
58 Surface *getCurrentReadSurface();
John Bauman66b8ab22014-05-06 15:57:45 -040059
Nicolas Capensa2308052015-04-15 16:50:21 -040060 void error(EGLint errorCode);
Nicolas Capens3f1ab0c2016-02-08 15:13:57 -050061
Nicolas Capensa2308052015-04-15 16:50:21 -040062 template<class T>
63 const T &error(EGLint errorCode, const T &returnValue)
64 {
65 egl::error(errorCode);
John Bauman66b8ab22014-05-06 15:57:45 -040066
Nicolas Capensa2308052015-04-15 16:50:21 -040067 return returnValue;
68 }
John Bauman66b8ab22014-05-06 15:57:45 -040069
Nicolas Capensa2308052015-04-15 16:50:21 -040070 template<class T>
71 const T &success(const T &returnValue)
72 {
73 egl::setCurrentError(EGL_SUCCESS);
John Bauman66b8ab22014-05-06 15:57:45 -040074
Nicolas Capensa2308052015-04-15 16:50:21 -040075 return returnValue;
76 }
John Bauman66b8ab22014-05-06 15:57:45 -040077}
78
Nicolas Capensa2308052015-04-15 16:50:21 -040079extern LibGLES_CM libGLES_CM;
80extern LibGLESv2 libGLESv2;
John Bauman66b8ab22014-05-06 15:57:45 -040081
82#endif // LIBEGL_MAIN_H_