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 RENDER_FRAME_BUFFER_H
17 #define RENDER_FRAME_BUFFER_H
18 
19 #include "base/render_base.h"
20 #include "core/render_resource_cache.h"
21 #include "graphic/render_context.h"
22 #include "graphic/render_texture.h"
23 #include "image_effect_marco_define.h"
24 
25 namespace OHOS {
26 namespace Media {
27 namespace Effect {
28 class ResourceCache;
29 class RenderFrameBuffer {
30 public:
31     IMAGE_EFFECT_EXPORT
32     RenderFrameBuffer(RenderContext *ctx, ResourceCache *cache, int width, int height, GLenum interFmt = GL_RGBA8);
33     IMAGE_EFFECT_EXPORT ~RenderFrameBuffer();
34 
35     IMAGE_EFFECT_EXPORT void Resize(int width, int height);
36     IMAGE_EFFECT_EXPORT RenderTexturePtr Texture() const;
37     IMAGE_EFFECT_EXPORT void Bind();
38     IMAGE_EFFECT_EXPORT void UnBind();
39     int Width();
40     int Height();
41 
42 private:
43     unsigned int fboId_ = GL_NONE;
44     RenderTexturePtr texture_;
45     RenderContext *context_{ nullptr };
46     ResourceCache *cache_{ nullptr };
47 };
48 
49 using RenderFrameBufferPtr = std::shared_ptr<RenderFrameBuffer>;
50 } // namespace Effect
51 } // namespace Media
52 } // namespace OHOS
53 #endif // RENDER_FRAME_BUFFER_H