• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2017 The Android Open Source Project
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 #pragma once
16 
17 #include "OpenGLESDispatch/EGLDispatch.h"
18 #include "OpenGLESDispatch/GLESv1Dispatch.h"
19 #include "OpenGLESDispatch/GLESv2Dispatch.h"
20 
21 namespace emugl {
22 
23 // Helper classes to hold global EGLDispatch, GLESv1Dispatch and GLESv2Dispatch
24 // objects, initialized lazily in a thread-safe way. The instances are leaked on
25 // program exit.
26 
27 struct LazyLoadedGLESv1Dispatch {
28     // Return pointer to global GLESv1Dispatch instance, or nullptr if there
29     // was an error when trying to initialize/load the library.
30     static const GLESv1Dispatch* get();
31 
32     LazyLoadedGLESv1Dispatch();
33 
34 private:
35     bool mValid;
36 };
37 
38 struct LazyLoadedGLESv2Dispatch {
39     // Return pointer to global GLESv2Dispatch instance, or nullptr if there
40     // was an error when trying to initialize/load the library.
41     static const GLESv2Dispatch* get();
42 
43     LazyLoadedGLESv2Dispatch();
44 
45 private:
46     bool mValid;
47 };
48 
49 // Note that the dispatch table is provided by libOpenGLESDispatch as the
50 // 's_egl' global variable.
51 struct LazyLoadedEGLDispatch {
52     // Return pointer to EGLDispatch table, or nullptr if there was
53     // an error when trying to initialize/load the library.
54     static const EGLDispatch* get();
55 
56     LazyLoadedEGLDispatch();
57 
58 private:
59     bool mValid;
60 };
61 
62 }  // namespace emugl