1 /*
2  * Copyright (c) 2021-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 OP_LIST_HANDLE_H
17 #define OP_LIST_HANDLE_H
18 
19 #include <vector>
20 #include "utils/rect.h"
21 #include "drawing/engine_adapter/impl_interface/OpListHandleImpl.h"
22 
23 namespace OHOS {
24 namespace Rosen {
25 namespace Drawing {
26 
27 enum CanDrawOpErrType : int {
28     CANDRAW_SUCCESS = 0,
29     CANDRAW_MULTIPLE = 1,
30     CANDRAW_NOTREUSED = 2,
31     CANDRAW_CHECKTRANS = 3,
32     CANDRAW_CHECKTRANS_TYPE = 4,
33     CANDRAW_NOCLIPRECT = 5,
34     CANDRAW_AFTERCLIP = 6,
35     CANDRAW_EMPTRPTR = 7,
36     CANDRAW_OPLIST_EMPTY = 8,
37 };
38 
39 class DRAWING_API OpListHandle {
40 public:
41 struct OpInfo {
42     bool canReUseCache = false;
43     int num = 0;
44     int percent = 0;
45     Rect unionRect;
46     std::vector<Rect> drawAreaRects;
47 };
48 
49     OpListHandle();
50     OpListHandle(OpInfo opinfo);
~OpListHandle()51     ~OpListHandle() {}
52 
GetOpInfo()53     const OpInfo &GetOpInfo() const
54     {
55         return opInfo_;
56     }
57 
ResetOpInfo()58     void ResetOpInfo()
59     {
60         opInfo_.canReUseCache = false;
61     }
62 
63 template<typename T>
GetImpl()64     T* GetImpl() const
65     {
66         return opImpl_->DowncastingTo<T>();
67     }
68 
69 private:
70     std::shared_ptr<OpListHandleImpl> opImpl_; // for opinc diff
71     OpInfo opInfo_;
72 };
73 } // namespace Drawing
74 } // namespace Rosen
75 } // namespace OHOS
76 #endif
77