• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 DRAW_CMD_LIST_H
17 #define DRAW_CMD_LIST_H
18 
19 #include "draw/canvas.h"
20 #include "recording/cmd_list.h"
21 
22 namespace OHOS {
23 namespace Rosen {
24 namespace Drawing {
25 class DrawCmdList : public CmdList {
26 public:
27     DrawCmdList() = default;
28     DrawCmdList(int32_t width, int32_t height);
29     ~DrawCmdList() override = default;
30 
GetType()31     uint32_t GetType() const override
32     {
33         return Type::DRAW_CMD_LIST;
34     }
35 
36     /*
37      * @brief       Creates a DrawCmdList with contiguous buffers.
38      * @param data  A contiguous buffers.
39      */
40     static std::shared_ptr<DrawCmdList> CreateFromData(const CmdListData& data, bool isCopy = false);
41 
42     /*
43      * @brief         Calls the corresponding operations of all opitems in DrawCmdList to the canvas.
44      * @param canvas  Implements the playback action of the DrawCmdList in the Canvas.
45      */
46     void Playback(Canvas& canvas, const Rect* rect = nullptr) const;
47 
48     /*
49      * @brief  Gets the width of the DrawCmdList.
50      */
51     int32_t GetWidth() const;
52 
53     /*
54      * @brief  Gets the height of the DrawCmdList.
55      */
56     int32_t GetHeight() const;
57 
58     /*
59      * @brief  Sets the width of the DrawCmdList.
60      */
61     void SetWidth(int32_t width);
62 
63     /*
64      * @brief  Sets the height of the DrawCmdList.
65      */
66     void SetHeight(int32_t height);
67 
68 private:
69     MemAllocator largeObjectAllocator_;
70     int32_t width_;
71     int32_t height_;
72 };
73 
74 using DrawCmdListPtr = std::shared_ptr<DrawCmdList>;
75 } // namespace Drawing
76 } // namespace Rosen
77 } // namespace OHOS
78 
79 #endif // DRAW_CMD_LIST_H
80