• 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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_XCOMPONENT_INNER_XCOMPONENT_CONTROLLER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_XCOMPONENT_INNER_XCOMPONENT_CONTROLLER_H
18 
19 #include <functional>
20 #include <string>
21 
22 #include "interfaces/inner_api/xcomponent_controller/xcomponent_controller.h"
23 
24 namespace OHOS::Ace {
25 class InnerXComponentController : public OHOS::Ace::XComponentController {
26 public:
27     InnerXComponentController() = default;
28     ~InnerXComponentController() override = default;
29 
30     using ConfigSurfaceImpl = std::function<void(uint32_t, uint32_t)>;
31 
GetSurfaceId()32     std::string GetSurfaceId()
33     {
34         return surfaceId_;
35     }
36 
SetSurfaceId(const std::string & surfaceId)37     void SetSurfaceId(const std::string& surfaceId)
38     {
39         surfaceId_ = surfaceId;
40     }
41 
ConfigSurface(uint32_t surfaceWidth,uint32_t surfaceHeight)42     void ConfigSurface(uint32_t surfaceWidth, uint32_t surfaceHeight)
43     {
44         if (configSurfaceImpl_) {
45             configSurfaceImpl_(surfaceWidth, surfaceHeight);
46         }
47     }
48 
SetConfigSurfaceImpl(ConfigSurfaceImpl && ConfigSurfaceImpl)49     void SetConfigSurfaceImpl(ConfigSurfaceImpl&& ConfigSurfaceImpl)
50     {
51         configSurfaceImpl_ = std::move(ConfigSurfaceImpl);
52     }
53 
54 private:
55     ConfigSurfaceImpl configSurfaceImpl_;
56     std::string surfaceId_;
57 };
58 } // namespace OHOS::Ace
59 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_XCOMPONENT_INNER_XCOMPONENT_CONTROLLER_H
60