1 /* 2 * Copyright (C) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OH_VEF_GL_UTILS_H 17 #define OH_VEF_GL_UTILS_H 18 19 #include <GLES3/gl3.h> 20 #include <cstdint> 21 #include "math/render_matrix.h" 22 #include "math/render_vector.h" 23 #include "render_context.h" 24 25 namespace OHOS { 26 namespace Media { 27 class GLUtils { 28 public: 29 static GLuint CreateTexture2D(GLsizei width, GLsizei height, GLenum internalFormat, GLint minFilter, 30 GLint magFilter); 31 32 static GLuint CreateTexture2DNoStorage(GLint minFilter, GLint magFilter, GLint wrapS, GLint wrapT); 33 34 static GLuint CreateFramebuffer(GLuint textureId = 0); 35 36 static void DeleteTexture(GLuint texture); 37 38 static void DeleteFboOnly(GLuint fbo); 39 40 static void CopyTexture(GLuint srcTexId, GLuint dstTexId, GLint width, GLint height); 41 42 static GLuint CreateTexNoStorage(GLenum target); 43 44 static size_t GetInternalFormatPixelByteSize(GLenum internalFormat); 45 46 static GLuint LoadShader(const std::string& src, uint32_t shaderType); 47 48 static GLuint CreateProgram(const std::string& vss, const std::string& fss); 49 50 static Mat4x4 GetOesSamplingMatrix(Vec2 bufferWH, Vec2 displayWH, int32_t angle, bool flip); 51 52 static void CheckError(const char* file, int32_t line); 53 }; 54 } 55 } 56 57 #endif