1e0dac50fSopenharmony_ci/*
2e0dac50fSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
3e0dac50fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e0dac50fSopenharmony_ci * you may not use this file except in compliance with the License.
5e0dac50fSopenharmony_ci * You may obtain a copy of the License at
6e0dac50fSopenharmony_ci *
7e0dac50fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e0dac50fSopenharmony_ci *
9e0dac50fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e0dac50fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e0dac50fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e0dac50fSopenharmony_ci * See the License for the specific language governing permissions and
13e0dac50fSopenharmony_ci * limitations under the License.
14e0dac50fSopenharmony_ci */
15e0dac50fSopenharmony_ci
16e0dac50fSopenharmony_ci#ifndef OHOS_ROSEN_DISPLAY_ZOOM_CONTROLLER_H
17e0dac50fSopenharmony_ci#define OHOS_ROSEN_DISPLAY_ZOOM_CONTROLLER_H
18e0dac50fSopenharmony_ci
19e0dac50fSopenharmony_ci#include <refbase.h>
20e0dac50fSopenharmony_ci
21e0dac50fSopenharmony_ci#include "window_node.h"
22e0dac50fSopenharmony_ci#include "window_root.h"
23e0dac50fSopenharmony_ci#include "window_node_container.h"
24e0dac50fSopenharmony_ci#include "wm_common.h"
25e0dac50fSopenharmony_ci
26e0dac50fSopenharmony_cinamespace OHOS::Rosen {
27e0dac50fSopenharmony_ciclass DisplayZoomController : public RefBase {
28e0dac50fSopenharmony_cipublic:
29e0dac50fSopenharmony_ci    explicit DisplayZoomController(sptr<WindowRoot>& root) : windowRoot_(root) {}
30e0dac50fSopenharmony_ci    ~DisplayZoomController() = default;
31e0dac50fSopenharmony_ci    void SetAnchorAndScale(int32_t x, int32_t y, float scale);
32e0dac50fSopenharmony_ci    void SetAnchorOffset(int32_t deltaX, int32_t deltaY);
33e0dac50fSopenharmony_ci    void OffWindowZoom();
34e0dac50fSopenharmony_ci    void UpdateAllWindowsZoomInfo(DisplayId displayId);
35e0dac50fSopenharmony_ci    void UpdateWindowZoomInfo(uint32_t windowId);
36e0dac50fSopenharmony_ci    void ClearZoomTransform(std::vector<sptr<WindowNode>> nodes);
37e0dac50fSopenharmony_ciprivate:
38e0dac50fSopenharmony_ci    struct DisplayZoomInfo {
39e0dac50fSopenharmony_ci        int32_t pivotX;
40e0dac50fSopenharmony_ci        int32_t pivotY;
41e0dac50fSopenharmony_ci        float scale;
42e0dac50fSopenharmony_ci        int32_t translateX;
43e0dac50fSopenharmony_ci        int32_t translateY;
44e0dac50fSopenharmony_ci    };
45e0dac50fSopenharmony_ci    sptr<WindowRoot> windowRoot_;
46e0dac50fSopenharmony_ci    void ClearZoomTransformInner(sptr<WindowNode> node);
47e0dac50fSopenharmony_ci    bool UpdateZoomTranslateInfo(sptr<WindowNodeContainer> windowNodeContainer, DisplayId displayId,
48e0dac50fSopenharmony_ci        int32_t& deltaX, int32_t& deltaY);
49e0dac50fSopenharmony_ci    Transform CalcuAnimateZoomTrans(sptr<WindowNode> node);
50e0dac50fSopenharmony_ci    Transform CalcuZoomTransByZoomInfo(sptr<WindowNode> node);
51e0dac50fSopenharmony_ci    Transform CalcuZoomTrans(sptr<WindowNode> node, const DisplayZoomInfo& zoomInfo);
52e0dac50fSopenharmony_ci    void UpdateClientAndSurfaceZoomInfo(sptr<WindowNode> node, const Transform& zoomTrans);
53e0dac50fSopenharmony_ci    void HandleUpdateWindowZoomInfo(sptr<WindowNode> node);
54e0dac50fSopenharmony_ci    void TransformSurfaceNode(std::shared_ptr<RSSurfaceNode> surfaceNode, const Transform& trans);
55e0dac50fSopenharmony_ci    DisplayZoomInfo zoomInfo_ = {0, 0, 1.0, 0, 0}; // compared with original window rect
56e0dac50fSopenharmony_ci    std::unordered_set<WindowType> displayZoomWindowTypeSkipped_ {
57e0dac50fSopenharmony_ci        WindowType::WINDOW_TYPE_NAVIGATION_BAR,
58e0dac50fSopenharmony_ci        WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT,
59e0dac50fSopenharmony_ci    };
60e0dac50fSopenharmony_ci};
61e0dac50fSopenharmony_ci}
62e0dac50fSopenharmony_ci#endif // OHOS_ROSEN_DISPLAY_ZOOM_CONTROLLER_H
63