Jason Macnak | d3a75bb | 2022-11-03 10:26:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 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 | #pragma once |
| 18 | |
| 19 | #include <memory> |
| 20 | #include <unordered_map> |
| 21 | #include <unordered_set> |
| 22 | |
| 23 | #include <EGL/egl.h> |
| 24 | #include <EGL/eglext.h> |
| 25 | |
| 26 | #include "Handle.h" |
| 27 | |
| 28 | namespace gfxstream { |
Jason Macnak | ed0c9e6 | 2023-03-30 15:58:24 -0700 | [diff] [blame] | 29 | namespace gl { |
Jason Macnak | d3a75bb | 2022-11-03 10:26:36 -0700 | [diff] [blame] | 30 | |
| 31 | class EmulatedEglImage { |
| 32 | public: |
| 33 | static std::unique_ptr<EmulatedEglImage> create(EGLDisplay display, |
| 34 | EGLContext context, |
| 35 | EGLenum target, |
Jason Macnak | 28feb52 | 2023-01-03 15:27:53 -0800 | [diff] [blame] | 36 | EGLClientBuffer buffer); |
Jason Macnak | d3a75bb | 2022-11-03 10:26:36 -0700 | [diff] [blame] | 37 | |
| 38 | ~EmulatedEglImage(); |
| 39 | |
| 40 | EGLBoolean destroy(); |
| 41 | |
Jason Macnak | 28feb52 | 2023-01-03 15:27:53 -0800 | [diff] [blame] | 42 | HandleType getHandle() const { return mHandle; } |
| 43 | |
Jason Macnak | d3a75bb | 2022-11-03 10:26:36 -0700 | [diff] [blame] | 44 | private: |
| 45 | EmulatedEglImage(HandleType handle, |
| 46 | EGLDisplay display, |
| 47 | EGLImageKHR image); |
| 48 | |
| 49 | const HandleType mHandle = 0; |
| 50 | EGLDisplay mEglDisplay = EGL_NO_DISPLAY; |
| 51 | EGLImageKHR mEglImage = EGL_NO_IMAGE_KHR; |
| 52 | }; |
| 53 | |
| 54 | typedef std::shared_ptr<EmulatedEglImage> EmulatedEglImagePtr; |
| 55 | typedef std::unordered_map<HandleType, EmulatedEglImagePtr> EmulatedEglImageMap; |
| 56 | typedef std::unordered_set<HandleType> EmulatedEglImageSet; |
| 57 | |
Jason Macnak | ed0c9e6 | 2023-03-30 15:58:24 -0700 | [diff] [blame] | 58 | } // namespace gl |
Jason Macnak | d3a75bb | 2022-11-03 10:26:36 -0700 | [diff] [blame] | 59 | } // namespace gfxstream |