blob: 8b2e46ca41cd9bdf04c5084ec165017c865b2da9 [file] [log] [blame]
Jason Macnakd3a75bb2022-11-03 10:26:36 -07001/*
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
28namespace gfxstream {
Jason Macnaked0c9e62023-03-30 15:58:24 -070029namespace gl {
Jason Macnakd3a75bb2022-11-03 10:26:36 -070030
31class EmulatedEglImage {
32 public:
33 static std::unique_ptr<EmulatedEglImage> create(EGLDisplay display,
34 EGLContext context,
35 EGLenum target,
Jason Macnak28feb522023-01-03 15:27:53 -080036 EGLClientBuffer buffer);
Jason Macnakd3a75bb2022-11-03 10:26:36 -070037
38 ~EmulatedEglImage();
39
40 EGLBoolean destroy();
41
Jason Macnak28feb522023-01-03 15:27:53 -080042 HandleType getHandle() const { return mHandle; }
43
Jason Macnakd3a75bb2022-11-03 10:26:36 -070044 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
54typedef std::shared_ptr<EmulatedEglImage> EmulatedEglImagePtr;
55typedef std::unordered_map<HandleType, EmulatedEglImagePtr> EmulatedEglImageMap;
56typedef std::unordered_set<HandleType> EmulatedEglImageSet;
57
Jason Macnaked0c9e62023-03-30 15:58:24 -070058} // namespace gl
Jason Macnakd3a75bb2022-11-03 10:26:36 -070059} // namespace gfxstream