1 /* 2 * Copyright (c) 2023-2024 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 enum class ImageAnalyzerState; 26 using OnAnalyzedCallback = std::optional<std::function<void(ImageAnalyzerState)>>; 27 class InnerXComponentController : public OHOS::Ace::XComponentController { 28 public: 29 InnerXComponentController() = default; 30 ~InnerXComponentController() override = default; 31 32 using ConfigSurfaceImpl = std::function<void(uint32_t, uint32_t)>; 33 GetSurfaceId()34 std::string GetSurfaceId() 35 { 36 return surfaceId_; 37 } 38 SetSurfaceId(const std::string & surfaceId)39 void SetSurfaceId(const std::string& surfaceId) 40 { 41 surfaceId_ = surfaceId; 42 } 43 ConfigSurface(uint32_t surfaceWidth,uint32_t surfaceHeight)44 void ConfigSurface(uint32_t surfaceWidth, uint32_t surfaceHeight) 45 { 46 if (configSurfaceImpl_) { 47 configSurfaceImpl_(surfaceWidth, surfaceHeight); 48 } 49 } 50 SetConfigSurfaceImpl(ConfigSurfaceImpl && ConfigSurfaceImpl)51 void SetConfigSurfaceImpl(ConfigSurfaceImpl&& ConfigSurfaceImpl) 52 { 53 configSurfaceImpl_ = std::move(ConfigSurfaceImpl); 54 } 55 GetLocalLocation(float & offsetX,float & offsetY)56 virtual void GetLocalLocation(float& offsetX, float& offsetY) {} GetSurfaceSize(float & surfaceWidth,float & surfaceHeight)57 virtual void GetSurfaceSize(float& surfaceWidth, float& surfaceHeight) {} 58 SetIdealSurfaceWidth(float surfaceWidth)59 virtual void SetIdealSurfaceWidth(float surfaceWidth) {} SetIdealSurfaceHeight(float surfaceHeight)60 virtual void SetIdealSurfaceHeight(float surfaceHeight) {} SetIdealSurfaceOffsetX(float offsetX)61 virtual void SetIdealSurfaceOffsetX(float offsetX) {} SetIdealSurfaceOffsetY(float offsetY)62 virtual void SetIdealSurfaceOffsetY(float offsetY) {} ClearIdealSurfaceOffset(bool isXAxis)63 virtual void ClearIdealSurfaceOffset(bool isXAxis) {} UpdateSurfaceBounds()64 virtual void UpdateSurfaceBounds() {} StartImageAnalyzer(void * config,OnAnalyzedCallback & onAnalyzed)65 virtual void StartImageAnalyzer(void* config, OnAnalyzedCallback& onAnalyzed) {} StopImageAnalyzer()66 virtual void StopImageAnalyzer() {} SetSurfaceRotation(bool isLock)67 virtual void SetSurfaceRotation(bool isLock) {} GetSurfaceRotation()68 virtual bool GetSurfaceRotation() 69 { 70 return false; 71 } 72 73 private: 74 ConfigSurfaceImpl configSurfaceImpl_; 75 std::string surfaceId_; 76 }; 77 } // namespace OHOS::Ace 78 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_XCOMPONENT_INNER_XCOMPONENT_CONTROLLER_H 79