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 #include "graphic/render_general_program.h"
17 #include "graphic/gl_utils.h"
18
19 #include "effect_trace.h"
20
21 namespace OHOS {
22 namespace Media {
23 namespace Effect {
RenderGeneralProgram(RenderContext * context,const std::string & vss,const std::string & fss)24 RenderGeneralProgram::RenderGeneralProgram(RenderContext *context, const std::string &vss, const std::string &fss)
25 : RenderProgram(context), vss_(vss), fss_(fss)
26 {
27 SetTag("RenderGeneralProgram");
28 }
29
30 RenderGeneralProgram::~RenderGeneralProgram() = default;
31
Init()32 bool RenderGeneralProgram::Init()
33 {
34 EFFECT_TRACE_NAME("Init RenderGeneralProgram");
35 program_ = GLUtils::CreateProgram(vss_, fss_);
36 SetReady(true);
37 return program_ <= 0 ? false : true;
38 }
39
Release()40 bool RenderGeneralProgram::Release()
41 {
42 if (IsReady()) {
43 glDeleteProgram(program_);
44 program_ = 0;
45 SetReady(false);
46 }
47 return true;
48 }
49 } // namespace Effect
50 } // namespace Media
51 } // namespace OHOS