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_PATTERN_SCREEN_PATTERN_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SCREEN_PATTERN_H 18 19 #include "session/screen/include/screen_session.h" 20 #include "core/components_ng/pattern/stack/stack_pattern.h" 21 #include "input_manager.h" 22 23 namespace OHOS::Ace::NG { 24 class ScreenPattern : public StackPattern { 25 DECLARE_ACE_TYPE(ScreenPattern, StackPattern); 26 27 public: 28 explicit ScreenPattern(const sptr<Rosen::ScreenSession>& screenSession); 29 ~ScreenPattern() override = default; 30 GetContextParam()31 std::optional<RenderContext::ContextParam> GetContextParam() const override 32 { 33 return RenderContext::ContextParam { RenderContext::ContextType::EXTERNAL }; 34 } 35 GetScreenSession()36 sptr<Rosen::ScreenSession> GetScreenSession() 37 { 38 return screenSession_; 39 } 40 uint32_t GetWindowPatternType() const override; 41 42 protected: 43 void OnAttachToFrameNode() override; 44 void OnDetachFromFrameNode(FrameNode* frameNode) override; 45 bool OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& changeConfig) override; 46 47 private: 48 void UpdateDisplayInfo(); 49 void UpdateRenderPivot(float pivotX, float pivotY); 50 void DeduplicateDisplayInfo(); 51 void UpdateToInputManager(float rotation); 52 void InputManagerUpdateDisplayInfo(RectF paintRect, MMI::DisplayInfo displayInfo, MMI::WindowInfo windowInfo); 53 float GetDensityInCurrentResolution(); 54 55 static float screenMaxWidth_; 56 static float screenMaxHeight_; 57 58 sptr<Rosen::ScreenSession> screenSession_; 59 60 ACE_DISALLOW_COPY_AND_MOVE(ScreenPattern); 61 }; 62 } // namespace OHOS::Ace::NG 63 64 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SCREEN_PATTERN_H 65