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