• 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 "surface_ohos.h"
17 
18 #include "surface_frame_ohos.h"
19 #include "surface_ohos_gl.h"
20 #include "surface_ohos_raster.h"
21 
22 namespace OHOS {
23 namespace Rosen {
SurfaceOhos(const sptr<Surface> & producer)24 SurfaceOhos::SurfaceOhos(const sptr<Surface>& producer)
25     : producer_(producer)
26 {
27     producer_->SetQueueSize(5);
28 }
29 
CreateSurface(sptr<Surface> surface)30 std::shared_ptr<SurfaceBase> SurfaceOhos::CreateSurface(sptr<Surface> surface)
31 {
32     auto type = Setting::GetRenderBackendType();
33     std::shared_ptr<SurfaceBase> producer = nullptr;
34     switch (type) {
35         case RenderBackendType::GLES:
36 #ifdef ACE_ENABLE_GL
37             LOGI("SurfaceOhos::CreateSurface with gles backend");
38             producer = std::make_shared<SurfaceOhosGl>(surface);
39 #endif
40             break;
41         case RenderBackendType::SOFTWARE:
42             LOGI("SurfaceOhos::CreateSurface with software backend");
43             producer = std::make_shared<SurfaceOhosRaster>(surface);
44             break;
45         default:
46             break;
47     }
48     return producer;
49 }
50 } // namespace Rosen
51 } // namespace OHOS