• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 "render_context_factory.h"
17 
18 #include "utils/log.h"
19 
20 #include "ohos/render_context_ohos_gl.h"
21 #include "ohos/render_context_ohos_raster.h"
22 #ifdef RS_ENABLE_VK
23 #include "ohos/render_context_ohos_vk.h"
24 #endif
25 
26 namespace OHOS {
27 namespace Rosen {
CreateRenderContext(RenderType renderType)28 std::shared_ptr<RenderContextBase> RenderContextBaseFactory::CreateRenderContext(RenderType renderType)
29 {
30     std::shared_ptr<RenderContextBase> renderContext;
31 #if defined(ROSEN_OHOS)
32     if (renderType == RenderType::GLES) {
33         renderContext = std::make_shared<RenderContextOhosGl>();
34     } else if (renderType == RenderType::RASTER) {
35         renderContext = std::make_shared<RenderContextOhosRaster>();
36     } else {
37 #ifdef RS_ENABLE_VK
38         renderContext = std::make_shared<RenderContextOhosVk>();
39 #endif
40     }
41     renderContext->SetPlatformName(PlatformName::OHOS);
42     renderContext->SetRenderType(renderType);
43 #endif
44     return renderContext;
45 }
46 }
47 }