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