Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2023 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_COMPANION_VIRTUALCAMERA_EGLDISPLAYCONTEXT_H |
| 18 | #define ANDROID_COMPANION_VIRTUALCAMERA_EGLDISPLAYCONTEXT_H |
| 19 | |
| 20 | #include "EGL/egl.h" |
| 21 | |
| 22 | namespace android { |
| 23 | namespace companion { |
| 24 | namespace virtualcamera { |
| 25 | |
| 26 | // Encapsulated EGLDisplay & EGLContext. |
| 27 | // |
| 28 | // Upon construction, this object will create and configure new |
| 29 | // EGLDisplay & EGLContext and will destroy them once it goes |
| 30 | // out of scope. |
| 31 | class EglDisplayContext { |
| 32 | public: |
| 33 | EglDisplayContext(); |
| 34 | ~EglDisplayContext(); |
| 35 | |
| 36 | // Sets EGLDisplay & EGLContext for current thread. |
| 37 | // |
| 38 | // Returns true on success, false otherwise. |
| 39 | bool makeCurrent(); |
| 40 | |
| 41 | EGLDisplay getEglDisplay() const; |
| 42 | |
| 43 | // Returns true if this instance encapsulates successfully initialized |
| 44 | // EGLDisplay & EGLContext. |
| 45 | bool isInitialized() const; |
| 46 | |
| 47 | private: |
| 48 | EGLDisplay mEglDisplay; |
| 49 | EGLContext mEglContext; |
| 50 | EGLConfig mEglConfig; |
| 51 | }; |
| 52 | |
| 53 | } // namespace virtualcamera |
| 54 | } // namespace companion |
| 55 | } // namespace android |
| 56 | |
| 57 | #endif // ANDROID_COMPANION_VIRTUALCAMERA_EGLDISPLAYCONTEXT_H |