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 <securec.h>
19 #include <sync_fence.h>
20
21 #include "graphic_common.h"
22 #include "graphic_common_c.h"
23 #include "nweb_log.h"
24 #include "surface_type.h"
25
26 namespace OHOS::NWeb {
27 class NWebDefaultOutputFrameCallback : public NWebOutputFrameCallback {
28 public:
29 NWebDefaultOutputFrameCallback() = default;
30 ~NWebDefaultOutputFrameCallback() = default;
31
Handle(const char * buffer,uint32_t width,uint32_t height)32 bool Handle(const char* buffer, uint32_t width, uint32_t height) override
33 {
34 return true;
35 }
36 };
37
Instance()38 NWebEnhanceSurfaceAdapter &NWebEnhanceSurfaceAdapter::Instance()
39 {
40 static NWebEnhanceSurfaceAdapter surfaceAdapter;
41 return surfaceAdapter;
42 }
43
GetCreateInfo(void * enhanceSurfaceInfo,std::shared_ptr<NWebEngineInitArgs> initArgs,uint32_t width,uint32_t height,bool incognitoMode)44 std::shared_ptr<NWebCreateInfoImpl> NWebEnhanceSurfaceAdapter::GetCreateInfo(void *enhanceSurfaceInfo,
45 std::shared_ptr<NWebEngineInitArgs> initArgs, uint32_t width, uint32_t height, bool incognitoMode)
46 {
47 std::shared_ptr<NWebCreateInfoImpl> createInfo = std::make_shared<NWebCreateInfoImpl>();
48 createInfo->SetWidth(width);
49 createInfo->SetHeight(height);
50 createInfo->SetEngineInitArgs(initArgs);
51 createInfo->SetIsIncognitoMode(incognitoMode);
52 createInfo->SetEnhanceSurfaceInfo(enhanceSurfaceInfo);
53 createInfo->SetOutputFrameCallback(std::make_shared<NWebDefaultOutputFrameCallback>());
54 return createInfo;
55 }
56 } // namespace OHOS::NWeb
57