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