• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 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 <string>
18 #include <vector>
19 
20 namespace android {
21 namespace opengl {
22 
23 class EmuglBackendList {
24 public:
25     // Parse the content of |execDir|/<lib>/ for Emugl backends.
26     // |programBitness| can be 0 (autodetect), 32 or 64, and determines
27     // the value of <lib> which will be 'lib' for 32-bit systems,
28     // and 'lib64' for 64-bit ones.
29     EmuglBackendList(const char* execDir, int programBitness);
30 
31     // Create a backend list with a fixed list of names
32     EmuglBackendList(int programBitness, const std::vector<std::string>& names);
33 
34     // Return the name of the default Emugl backend.
defaultName()35     const std::string& defaultName() const { return mDefaultName; }
36 
37     // Return the list of installed Emugl backends.
names()38     const std::vector<std::string>& names() const { return mNames; }
39 
40     // Returns true if |name| is part of names().
41     bool contains(const char* name) const;
42 
43     // Convert the name of an Emugl backend into the path of the
44     // corresponding sub-directory, if it exits, or NULL otherwise.
45     std::string getLibDirPath(const char* name);
46 
47     // List of supported Emugl shared libraries.
48     enum Library {
49         LIBRARY_NONE,
50         LIBRARY_EGL,
51         LIBRARY_GLESv1,
52         LIBRARY_GLESv2,
53         LIBRARY_GLES12TR
54     };
55 
56     // Probe the library directory for Emugl backend |name| and return
57     // the path of one of the EmuGL shared libraries for it. The result
58     // will be empty if there is no such library.
59     // |library| is a library type. On success, return true and sets
60     // |*libPath| to the library's path value. On failure, return false.
61     bool getBackendLibPath(const char* name, Library library,
62                            std::string* libPath);
63 
64 private:
65     std::string mDefaultName;
66     std::vector<std::string> mNames;
67     int mProgramBitness;
68     std::string mExecDir;
69 };
70 
71 }  // namespace opengl
72 }  // namespace android
73