• 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 "nweb_enhance_surface_adapter.h"
17 
18 #include <display_type.h>
19 #include <securec.h>
20 #include <sync_fence.h>
21 
22 #include "graphic_common.h"
23 #include "graphic_common_c.h"
24 #include "nweb_log.h"
25 #include "surface_type.h"
26 
27 namespace OHOS::NWeb {
Instance()28 NWebEnhanceSurfaceAdapter &NWebEnhanceSurfaceAdapter::Instance()
29 {
30     static NWebEnhanceSurfaceAdapter surfaceAdapter;
31     return surfaceAdapter;
32 }
33 
GetCreateInfo(void * enhanceSurfaceInfo,const NWebInitArgs & initArgs,uint32_t width,uint32_t height)34 NWebCreateInfo NWebEnhanceSurfaceAdapter::GetCreateInfo(void *enhanceSurfaceInfo,
35                                                         const NWebInitArgs &initArgs,
36                                                         uint32_t width,
37                                                         uint32_t height)
38 {
39     NWebCreateInfo createInfo = {
40         .init_args = initArgs,
41         .enhance_surface_info = enhanceSurfaceInfo,
42     };
43     GetSize(createInfo, width, height);
44     GetRenderInterface(createInfo);
45     return createInfo;
46 }
47 
GetSize(NWebCreateInfo & createInfo,uint32_t width,uint32_t height) const48 void NWebEnhanceSurfaceAdapter::GetSize(NWebCreateInfo &createInfo,
49                                         uint32_t width,
50                                         uint32_t height) const
51 {
52     createInfo.width = width;
53     createInfo.height = height;
54 }
55 
GetRenderInterface(NWebCreateInfo & createInfo)56 void NWebEnhanceSurfaceAdapter::GetRenderInterface(NWebCreateInfo &createInfo)
57 {
58     createInfo.output_render_frame = [] (const char *buffer, uint32_t width, uint32_t height) -> bool {
59         return true;
60     };
61 }
62 } // namespace OHOS::NWeb
63