blob: 0b89c70f443c4e72764cedb0ec344f5c0d8b9250 [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
50 int32_t queryWidth() const override;
51 int32_t queryHeight() const override;
52
53 bool getAsync() const { return mAsync; }
54 EGLSurface getEGLSurface() const { return mEGLSurface; }
55
56private:
57 EGLint queryConfig(EGLint attrib) const;
58 EGLint querySurface(EGLint attrib) const;
59
60 EGLDisplay mEGLDisplay;
61 EGLConfig mEGLConfig;
62
63 bool mCritical = false;
64 bool mAsync = false;
65
66 ANativeWindow* mWindow = nullptr;
67 EGLSurface mEGLSurface = EGL_NO_SURFACE;
68
69 DISALLOW_COPY_AND_ASSIGN(GLSurface);
70};
71
72} // namespace gl
73} // namespace renderengine
74} // namespace android