blob: 1b5f2cdd1d3373072b839b1167f6e9e086fcefe2 [file] [log] [blame]
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +01001/*
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
22namespace android {
23namespace companion {
24namespace virtualcamera {
25
26// Base class for EGL Shader programs representation.
27class 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.
43class 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.
56class EglTextureProgram : public EglProgram {
57 public:
Jan Sebechlebsky042d1fb2023-12-12 16:37:00 +010058 enum class TextureFormat { RGBA, YUV };
59
60 EglTextureProgram(TextureFormat textureFormat = TextureFormat::YUV);
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +010061
62 bool draw(GLuint textureId);
63};
64
65} // namespace virtualcamera
66} // namespace companion
67} // namespace android
68
69#endif // ANDROID_COMPANION_VIRTUALCAMERA_EGLPROGRAM_H