blob: 092d371ee9d3a0eca3b615b92789bce4e04d9a72 [file] [log] [blame]
Alec Mourif1d19c72018-11-15 00:00:50 +00001/*
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
50 bool getAsync() const { return mAsync; }
51 EGLSurface getEGLSurface() const { return mEGLSurface; }
52
53 int32_t getWidth() const override;
54 int32_t getHeight() const override;
55
56private:
57 EGLint queryConfig(EGLint attrib) const;
58
59 EGLDisplay mEGLDisplay;
60 EGLConfig mEGLConfig;
61
62 bool mCritical = false;
63 bool mAsync = false;
64
65 int32_t mSurfaceWidth = 0;
66 int32_t mSurfaceHeight = 0;
67
68 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