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