blob: 8aa223a93db5feefe41e3ad22bb64d75ccbd5516 [file] [log] [blame]
Peiyong Linf1bada92018-08-29 09:39:31 -07001/*
2 * Copyright 2018 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#include <android-base/macros.h>
23#include <renderengine/Surface.h>
24
25struct ANativeWindow;
26
27namespace android {
28namespace renderengine {
29namespace gl {
30
31class GLES20RenderEngine;
32
33class GLSurface final : public renderengine::Surface {
34public:
35 GLSurface(const GLES20RenderEngine& engine);
36 ~GLSurface() override;
37
38 // renderengine::Surface implementation
39 void setCritical(bool enable) override { mCritical = enable; }
40 void setAsync(bool enable) override { mAsync = enable; }
41
42 void setNativeWindow(ANativeWindow* window) override;
43 void swapBuffers() const override;
44
45 int32_t queryRedSize() const override;
46 int32_t queryGreenSize() const override;
47 int32_t queryBlueSize() const override;
48 int32_t queryAlphaSize() const override;
49
Peiyong Linf1bada92018-08-29 09:39:31 -070050 bool getAsync() const { return mAsync; }
51 EGLSurface getEGLSurface() const { return mEGLSurface; }
52
Alec Mouri05483a02018-09-10 21:03:42 +000053 int32_t getWidth() const override;
54 int32_t getHeight() const override;
55
Peiyong Linf1bada92018-08-29 09:39:31 -070056private:
57 EGLint queryConfig(EGLint attrib) const;
Peiyong Linf1bada92018-08-29 09:39:31 -070058
59 EGLDisplay mEGLDisplay;
60 EGLConfig mEGLConfig;
61
62 bool mCritical = false;
63 bool mAsync = false;
64
Alec Mouri05483a02018-09-10 21:03:42 +000065 int32_t mSurfaceWidth = 0;
66 int32_t mSurfaceHeight = 0;
67
Peiyong Linf1bada92018-08-29 09:39:31 -070068 ANativeWindow* mWindow = nullptr;
69 EGLSurface mEGLSurface = EGL_NO_SURFACE;
70
71 DISALLOW_COPY_AND_ASSIGN(GLSurface);
72};
73
74} // namespace gl
75} // namespace renderengine
76} // namespace android