• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef OHOS_ROSEN_DISPLAY_ZOOM_CONTROLLER_H
17 #define OHOS_ROSEN_DISPLAY_ZOOM_CONTROLLER_H
18 
19 #include <refbase.h>
20 
21 #include "window_node.h"
22 #include "window_root.h"
23 #include "window_node_container.h"
24 #include "wm_common.h"
25 
26 namespace OHOS::Rosen {
27 class DisplayZoomController : public RefBase {
28 public:
DisplayZoomController(sptr<WindowRoot> & root)29     explicit DisplayZoomController(sptr<WindowRoot>& root) : windowRoot_(root) {}
30     ~DisplayZoomController() = default;
31     void SetAnchorAndScale(int32_t x, int32_t y, float scale);
32     void SetAnchorOffset(int32_t deltaX, int32_t deltaY);
33     void OffWindowZoom();
34     void UpdateAllWindowsZoomInfo(DisplayId displayId);
35     void UpdateWindowZoomInfo(uint32_t windowId);
36     void ClearZoomTransform(std::vector<sptr<WindowNode>> nodes);
37 private:
38     struct DisplayZoomInfo {
39         int32_t pivotX;
40         int32_t pivotY;
41         float scale;
42         int32_t translateX;
43         int32_t translateY;
44     };
45     sptr<WindowRoot> windowRoot_;
46     void ClearZoomTransformInner(sptr<WindowNode> node);
47     bool UpdateZoomTranslateInfo(sptr<WindowNodeContainer> windowNodeContainer, DisplayId displayId,
48         int32_t& deltaX, int32_t& deltaY);
49     Transform CalcuAnimateZoomTrans(sptr<WindowNode> node);
50     Transform CalcuZoomTransByZoomInfo(sptr<WindowNode> node);
51     Transform CalcuZoomTrans(sptr<WindowNode> node, const DisplayZoomInfo& zoomInfo);
52     void UpdateClientAndSurfaceZoomInfo(sptr<WindowNode> node, const Transform& zoomTrans);
53     void HandleUpdateWindowZoomInfo(sptr<WindowNode> node);
54     void TransformSurfaceNode(std::shared_ptr<RSSurfaceNode> surfaceNode, const Transform& trans);
55     DisplayZoomInfo zoomInfo_ = {0, 0, 1.0, 0, 0}; // compared with original window rect
56     std::unordered_set<WindowType> displayZoomWindowTypeSkipped_ {
57         WindowType::WINDOW_TYPE_NAVIGATION_BAR,
58         WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT,
59     };
60 };
61 }
62 #endif // OHOS_ROSEN_DISPLAY_ZOOM_CONTROLLER_H
63