• 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 gfxstream {
22 namespace gl {
23 
24 // Helper classes to hold global EGLDispatch, GLESv1Dispatch and GLESv2Dispatch
25 // objects, initialized lazily in a thread-safe way. The instances are leaked on
26 // program exit.
27 
28 struct LazyLoadedGLESv1Dispatch {
29     // Return pointer to global GLESv1Dispatch instance, or nullptr if there
30     // was an error when trying to initialize/load the library.
31     static const GLESv1Dispatch* get();
32 
33     LazyLoadedGLESv1Dispatch();
34 
35 private:
36     bool mValid;
37 };
38 
39 struct LazyLoadedGLESv2Dispatch {
40     // Return pointer to global GLESv2Dispatch instance, or nullptr if there
41     // was an error when trying to initialize/load the library.
42     static const GLESv2Dispatch* get();
43 
44     LazyLoadedGLESv2Dispatch();
45 
46 private:
47     bool mValid;
48 };
49 
50 // Note that the dispatch table is provided by libOpenGLESDispatch as the
51 // 's_egl' global variable.
52 struct LazyLoadedEGLDispatch {
53     // Return pointer to EGLDispatch table, or nullptr if there was
54     // an error when trying to initialize/load the library.
55     static const EGLDispatch* get();
56 
57     LazyLoadedEGLDispatch();
58 
59 private:
60     bool mValid;
61 };
62 
63 }  // namespace gl
64 }  // namespace gfxstream