| Cody Northrop | 629ce4e | 2018-10-15 07:22:09 -0600 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2018 The Android Open Source Project | 
|  | 3 | * | 
|  | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | * you may not use this file except in compliance with the License. | 
|  | 6 | * You may obtain a copy of the License at | 
|  | 7 | * | 
|  | 8 | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | * | 
|  | 10 | * Unless required by applicable law or agreed to in writing, software | 
|  | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | * See the License for the specific language governing permissions and | 
|  | 14 | * limitations under the License. | 
|  | 15 | */ | 
|  | 16 |  | 
|  | 17 | #ifndef ANDROID_EGL_LAYERS_H | 
|  | 18 | #define ANDROID_EGL_LAYERS_H | 
|  | 19 |  | 
|  | 20 | #include <string> | 
|  | 21 | #include <unordered_map> | 
|  | 22 | #include <vector> | 
|  | 23 |  | 
|  | 24 | #include <EGL/egldefs.h> | 
|  | 25 |  | 
|  | 26 | #include "egl_platform_entries.h" | 
|  | 27 |  | 
|  | 28 | typedef __eglMustCastToProperFunctionPointerType EGLFuncPointer; | 
|  | 29 |  | 
|  | 30 | namespace android { | 
|  | 31 |  | 
|  | 32 | class LayerLoader { | 
|  | 33 | public: | 
|  | 34 | static LayerLoader& getInstance(); | 
|  | 35 | ~LayerLoader(){}; | 
|  | 36 |  | 
|  | 37 | typedef void* (*PFNEGLGETNEXTLAYERPROCADDRESSPROC)(void*, const char*); | 
|  | 38 | typedef EGLFuncPointer (*layer_init_func)( | 
|  | 39 | const void* layer_id, PFNEGLGETNEXTLAYERPROCADDRESSPROC get_next_layer_proc_address); | 
|  | 40 | typedef EGLFuncPointer (*layer_setup_func)(const char* name, EGLFuncPointer next); | 
|  | 41 |  | 
|  | 42 | void LoadLayers(); | 
|  | 43 | void InitLayers(egl_connection_t*); | 
|  | 44 | void LayerPlatformEntries(layer_setup_func layer_setup, EGLFuncPointer*, char const* const*); | 
|  | 45 | void LayerDriverEntries(layer_setup_func layer_setup, EGLFuncPointer*, char const* const*); | 
|  | 46 | bool Initialized(); | 
|  | 47 | std::string GetDebugLayers(); | 
|  | 48 |  | 
|  | 49 | EGLFuncPointer GetGpaNext(unsigned i); | 
|  | 50 | EGLFuncPointer ApplyLayer(layer_setup_func layer_setup, const char* name, EGLFuncPointer next); | 
|  | 51 | EGLFuncPointer ApplyLayers(const char* name, EGLFuncPointer next); | 
|  | 52 |  | 
|  | 53 | std::vector<layer_init_func> layer_init_; | 
|  | 54 | std::vector<layer_setup_func> layer_setup_; | 
|  | 55 |  | 
|  | 56 | private: | 
|  | 57 | LayerLoader() : layers_loaded_(false), initialized_(false), current_layer_(0){}; | 
|  | 58 | bool layers_loaded_; | 
|  | 59 | bool initialized_; | 
|  | 60 | unsigned current_layer_; | 
|  | 61 | }; | 
|  | 62 |  | 
|  | 63 | }; // namespace android | 
|  | 64 |  | 
|  | 65 | #endif // ANDROID_EGL_LAYERS_H |