• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 "image_chain.h"
17 
18 namespace OHOS {
19 namespace Rosen {
ImageChain(std::vector<std::shared_ptr<Input>> inputs)20 ImageChain::ImageChain(std::vector<std::shared_ptr<Input> > inputs) : inputs_(inputs)
21 {
22     CreatTexture(srcTextureID_);
23     CreatTexture(dstTextureID_);
24 
25     glGenFramebuffers(1, &frameBufferID_);
26     if (inputs_.size() == 1) {
27         flagSeries_ = true;
28     }
29 }
30 
Render()31 void ImageChain::Render()
32 {
33     if (flagSeries_) {
34         ProcessData data {srcTextureID_, dstTextureID_, frameBufferID_, 0, 0};
35         SeriesRendering(data);
36     }
37 
38     if (!flagSeries_) {
39         ParallelRendering();
40     }
41 }
42 
SeriesRendering(ProcessData & data)43 void ImageChain::SeriesRendering(ProcessData& data)
44 {
45     inputs_.at(0)->Process(data);
46 }
47 
CreatTexture(unsigned int & textureID)48 void ImageChain::CreatTexture(unsigned int& textureID)
49 {
50     glGenTextures(1, &textureID);
51     glBindTexture(GL_TEXTURE_2D, textureID);
52     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
53     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
54     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
55     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
56     glBindTexture(GL_TEXTURE_2D, 0);
57 }
58 } // namespcae Rosen
59 } // namespace OHOS