egl_layers.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #ifndef ANDROID_EGL_LAYERS_H
  17. #define ANDROID_EGL_LAYERS_H
  18. #include <string>
  19. #include <unordered_map>
  20. #include <vector>
  21. #include <EGL/egldefs.h>
  22. #include "egl_platform_entries.h"
  23. typedef __eglMustCastToProperFunctionPointerType EGLFuncPointer;
  24. namespace android {
  25. class LayerLoader {
  26. public:
  27. static LayerLoader& getInstance();
  28. ~LayerLoader(){};
  29. typedef void* (*PFNEGLGETNEXTLAYERPROCADDRESSPROC)(void*, const char*);
  30. typedef EGLFuncPointer (*layer_init_func)(
  31. const void* layer_id, PFNEGLGETNEXTLAYERPROCADDRESSPROC get_next_layer_proc_address);
  32. typedef EGLFuncPointer (*layer_setup_func)(const char* name, EGLFuncPointer next);
  33. void LoadLayers();
  34. void InitLayers(egl_connection_t*);
  35. void LayerPlatformEntries(layer_setup_func layer_setup, EGLFuncPointer*, char const* const*);
  36. void LayerDriverEntries(layer_setup_func layer_setup, EGLFuncPointer*, char const* const*);
  37. bool Initialized();
  38. std::string GetDebugLayers();
  39. EGLFuncPointer GetGpaNext(unsigned i);
  40. EGLFuncPointer ApplyLayer(layer_setup_func layer_setup, const char* name, EGLFuncPointer next);
  41. EGLFuncPointer ApplyLayers(const char* name, EGLFuncPointer next);
  42. std::vector<layer_init_func> layer_init_;
  43. std::vector<layer_setup_func> layer_setup_;
  44. private:
  45. LayerLoader() : layers_loaded_(false), initialized_(false), current_layer_(0){};
  46. bool layers_loaded_;
  47. bool initialized_;
  48. unsigned current_layer_;
  49. };
  50. }; // namespace android
  51. #endif // ANDROID_EGL_LAYERS_H