Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2023 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 | #ifndef ANDROID_COMPANION_VIRTUALCAMERA_EGLPROGRAM_H |
| 18 | #define ANDROID_COMPANION_VIRTUALCAMERA_EGLPROGRAM_H |
| 19 | |
| 20 | #include "GLES/gl.h" |
| 21 | |
| 22 | namespace android { |
| 23 | namespace companion { |
| 24 | namespace virtualcamera { |
| 25 | |
| 26 | // Base class for EGL Shader programs representation. |
| 27 | class EglProgram { |
| 28 | public: |
| 29 | virtual ~EglProgram(); |
| 30 | |
| 31 | // Returns whether the EGL Program was successfully compiled and linked. |
| 32 | bool isInitialized() const; |
| 33 | |
| 34 | protected: |
| 35 | // Compile & link program from the vertex & fragment shader source. |
| 36 | bool initialize(const char* vertexShaderSrc, const char* fragmentShaderSrc); |
| 37 | GLuint mProgram; |
| 38 | // Whether the EGL Program was successfully compiled and linked. |
| 39 | bool mIsInitialized = false; |
| 40 | }; |
| 41 | |
| 42 | // Shader program to draw Julia Set test pattern. |
| 43 | class EglTestPatternProgram : public EglProgram { |
| 44 | public: |
| 45 | EglTestPatternProgram(); |
| 46 | |
| 47 | bool draw(int width, int height, int frameNumber); |
| 48 | }; |
| 49 | |
| 50 | // Shader program to draw texture. |
| 51 | // |
| 52 | // Shader stretches the texture over the viewport (if the texture is not same |
| 53 | // aspect ratio as viewport, it will be deformed). |
| 54 | // |
| 55 | // TODO(b/301023410) Add support for translation / cropping. |
| 56 | class EglTextureProgram : public EglProgram { |
| 57 | public: |
| 58 | EglTextureProgram(); |
| 59 | |
| 60 | bool draw(GLuint textureId); |
| 61 | }; |
| 62 | |
| 63 | } // namespace virtualcamera |
| 64 | } // namespace companion |
| 65 | } // namespace android |
| 66 | |
| 67 | #endif // ANDROID_COMPANION_VIRTUALCAMERA_EGLPROGRAM_H |