blob: 8b10be9303923aa554d1e92368ab682ca7f0c6aa [file] [log] [blame]
Chia-I Wu7e60ecc2017-11-09 11:04:45 -08001/*
2 * Copyright 2017 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 <cstdint>
20
21#include <EGL/egl.h>
22
23struct ANativeWindow;
24
25namespace android {
26
27class RenderEngine;
28
29namespace RE {
30
31class Surface {
32public:
33 Surface(const RenderEngine& engine);
34 ~Surface();
35
36 Surface(const Surface&) = delete;
37 Surface& operator=(const Surface&) = delete;
38
39 void setCritical(bool enable) { mCritical = enable; }
40 void setAsync(bool enable) { mAsync = enable; }
41
42 void setNativeWindow(ANativeWindow* window);
43 void swapBuffers() const;
44
45 int32_t queryRedSize() const;
46 int32_t queryGreenSize() const;
47 int32_t queryBlueSize() const;
48 int32_t queryAlphaSize() const;
49
50 int32_t queryWidth() const;
51 int32_t queryHeight() const;
52
53private:
54 EGLint queryConfig(EGLint attrib) const;
55 EGLint querySurface(EGLint attrib) const;
56
57 // methods internal to RenderEngine
58 friend class android::RenderEngine;
59 bool getAsync() const { return mAsync; }
60 EGLSurface getEGLSurface() const { return mEGLSurface; }
61
62 EGLDisplay mEGLDisplay;
63 EGLConfig mEGLConfig;
64
65 bool mCritical = false;
66 bool mAsync = false;
67
68 ANativeWindow* mWindow = nullptr;
69 EGLSurface mEGLSurface = EGL_NO_SURFACE;
70};
71
72} // namespace RE
73} // namespace android