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 IMAGE_EFFECT_GPU_BRIGHTNESS_ALGO_H 17 #define IMAGE_EFFECT_GPU_BRIGHTNESS_ALGO_H 18 19 #include "error_code.h" 20 #include "effect_buffer.h" 21 #include "any.h" 22 23 #include "core/render_default_data.h" 24 #include "core/algorithm_program.h" 25 #include "render_environment.h" 26 #include "effect_context.h" 27 28 namespace OHOS { 29 namespace Media { 30 namespace Effect { 31 class BrightnessFilterData { 32 public: 33 RenderTexturePtr inputTexture_ = nullptr; 34 unsigned int outputWidth_; 35 unsigned int outputHeight_; 36 float ratio; 37 }; 38 using BrightnessFilterDataPtr = std::shared_ptr<BrightnessFilterData>; 39 class GpuBrightnessAlgo { 40 public: 41 ErrorCode OnApplyRGBA8888(EffectBuffer *src, EffectBuffer *dst, std::map<std::string, Plugin::Any> &value, 42 const std::shared_ptr<EffectContext> &context); 43 ErrorCode Release(); 44 ErrorCode Init(); 45 void Render(GLenum target, RenderTexturePtr tex); 46 private: 47 float ParseBrightness(std::map<std::string, Plugin::Any> &value); 48 BrightnessFilterDataPtr renderEffectData_; 49 void PreDraw(GLenum target); 50 void PostDraw(GLenum target); 51 RenderContext *context_{ nullptr }; 52 std::string vertexShaderCode_; 53 std::string fragmentShaderCode_; 54 GLuint fbo_{ 0 }; 55 AlgorithmProgram *shader_{ nullptr }; 56 RenderMesh *renderMesh_{ nullptr }; 57 }; 58 } // namespace Effect 59 } // namespace Media 60 } // namespace OHOS 61 62 #endif // IMAGE_EFFECT_GPU_BRIGHTNESS_ALGO_H