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 { 29 namespace gl { 30 31 class EmulatedEglImage { 32 public: 33 static std::unique_ptr<EmulatedEglImage> create(EGLDisplay display, 34 EGLContext context, 35 EGLenum target, 36 EGLClientBuffer buffer); 37 38 ~EmulatedEglImage(); 39 40 EGLBoolean destroy(); 41 getHandle()42 HandleType getHandle() const { return mHandle; } 43 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 58 } // namespace gl 59 } // namespace gfxstream 60