Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 1 | /* |
| 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 <EGL/eglext.h> |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame^] | 23 | #include <GLES2/gl2.h> |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 24 | #include <renderengine/Framebuffer.h> |
| 25 | |
| 26 | struct ANativeWindowBuffer; |
| 27 | |
| 28 | namespace android { |
| 29 | namespace renderengine { |
| 30 | namespace gl { |
| 31 | |
Peiyong Lin | 7e219eb | 2018-12-03 05:40:42 -0800 | [diff] [blame] | 32 | class GLESRenderEngine; |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 33 | |
| 34 | class GLFramebuffer : public renderengine::Framebuffer { |
| 35 | public: |
Alec Mouri | da4cf3b | 2019-02-12 15:33:01 -0800 | [diff] [blame] | 36 | explicit GLFramebuffer(GLESRenderEngine& engine); |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame^] | 37 | explicit GLFramebuffer(GLESRenderEngine& engine, bool multiTarget); |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 38 | ~GLFramebuffer() override; |
| 39 | |
Alec Mouri | fe0d72b | 2019-03-21 14:05:56 -0700 | [diff] [blame] | 40 | bool setNativeWindowBuffer(ANativeWindowBuffer* nativeBuffer, bool isProtected, |
| 41 | const bool useFramebufferCache) override; |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame^] | 42 | void allocateBuffers(uint32_t width, uint32_t height); |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 43 | EGLImageKHR getEGLImage() const { return mEGLImage; } |
| 44 | uint32_t getTextureName() const { return mTextureName; } |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame^] | 45 | uint32_t getSecondaryTextureName() const { return mSecondaryTextureName; } |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 46 | uint32_t getFramebufferName() const { return mFramebufferName; } |
Alec Mouri | 05483a0 | 2018-09-10 21:03:42 +0000 | [diff] [blame] | 47 | int32_t getBufferHeight() const { return mBufferHeight; } |
| 48 | int32_t getBufferWidth() const { return mBufferWidth; } |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame^] | 49 | GLenum getStatus() const { return mStatus; } |
| 50 | void bind() const; |
| 51 | void unbind() const; |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 52 | |
| 53 | private: |
Alec Mouri | da4cf3b | 2019-02-12 15:33:01 -0800 | [diff] [blame] | 54 | GLESRenderEngine& mEngine; |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 55 | EGLDisplay mEGLDisplay; |
| 56 | EGLImageKHR mEGLImage; |
Alec Mouri | fe0d72b | 2019-03-21 14:05:56 -0700 | [diff] [blame] | 57 | bool usingFramebufferCache = false; |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame^] | 58 | GLenum mStatus = GL_FRAMEBUFFER_UNSUPPORTED; |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 59 | uint32_t mTextureName, mFramebufferName; |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame^] | 60 | uint32_t mSecondaryTextureName = -1; |
Alec Mouri | 05483a0 | 2018-09-10 21:03:42 +0000 | [diff] [blame] | 61 | |
| 62 | int32_t mBufferHeight = 0; |
| 63 | int32_t mBufferWidth = 0; |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 64 | }; |
| 65 | |
Peiyong Lin | 46080ef | 2018-10-26 18:43:14 -0700 | [diff] [blame] | 66 | } // namespace gl |
| 67 | } // namespace renderengine |
| 68 | } // namespace android |