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