blob: 402ca3c615c6a7e8996e1b8eaa3a31baba452d32 [file] [log] [blame]
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +01001/*
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
22namespace android {
23namespace companion {
24namespace 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.
31class 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