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 FOUNDATION_ACE_ADAPTER_OHOS_OSAL_DRAG_WINDOW_OHOS_H
17 #define FOUNDATION_ACE_ADAPTER_OHOS_OSAL_DRAG_WINDOW_OHOS_H
18 
19 #include "wm/window.h"
20 #include "wm/window_option.h"
21 #include "wm/wm_common.h"
22 
23 #ifdef ENABLE_ROSEN_BACKEND
24 #include "render_service_client/core/ui/rs_ui_director.h"
25 #include "transaction/rs_transaction_proxy.h"
26 #include "ui/rs_root_node.h"
27 #endif
28 
29 #include "base/window/drag_window.h"
30 
31 namespace OHOS::Ace {
32 class DragWindowOhos : public DragWindow {
33 public:
DragWindowOhos(OHOS::sptr<OHOS::Rosen::Window> dragWindow)34     explicit DragWindowOhos(OHOS::sptr<OHOS::Rosen::Window> dragWindow) : dragWindow_(dragWindow) {}
35     ~DragWindowOhos() = default;
36 
37     void MoveTo(int32_t x, int32_t y) const override;
38     void TextDragWindowMove(double x, double y) const override;
39     void Destroy() const override;
40     void DrawPixelMap(const RefPtr<PixelMap>& pixelMap) override;
41     void DrawFrameNode(const RefPtr<NG::FrameNode>& rootNode) override;
42 #ifndef USE_ROSEN_DRAWING
43     void DrawImage(void* skImage) override;
44 #else
45     void DrawImage(void* drawingImage) override;
46 #endif
47 #ifndef USE_GRAPHIC_TEXT_GINE
48     void DrawText(
49         std::shared_ptr<txt::Paragraph> paragraph, const Offset& offset, const RefPtr<RenderText>& renderText) override;
50 #else
51     void DrawText(std::shared_ptr<Rosen::Typography> paragraph, const Offset& offset,
52         const RefPtr<RenderText>& renderText) override;
53 #endif
54     void DrawTextNG(const RefPtr<NG::Paragraph>& paragraph, const RefPtr<NG::TextPattern>& textPattern) override;
55 
56 private:
57     OHOS::sptr<Rosen::Window> dragWindow_;
58 #ifdef ENABLE_ROSEN_BACKEND
59     std::shared_ptr<Rosen::RSNode> rootNode_;
60     std::shared_ptr<Rosen::RSUIDirector> rsUiDirector_;
61 #endif
62 };
63 } // namespace OHOS::Ace
64 
65 #endif // FOUNDATION_ACE_ADAPTER_OHOS_OSAL_DRAG_WINDOW_OHOS_H