• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 FRAMEWORKS_BRIDGE_CJ_FRONTEND_CPP_VIEW_CANVAS_IMAGE_DATA_H
17 #define FRAMEWORKS_BRIDGE_CJ_FRONTEND_CPP_VIEW_CANVAS_IMAGE_DATA_H
18 
19 #include "ffi_remote_data.h"
20 
21 #include "base/memory/referenced.h"
22 #include "core/components/common/properties/decoration.h"
23 #include "frameworks/core/components/common/properties/paint_state.h"
24 
25 namespace OHOS::Ace::Framework {
26 
27 class ACE_EXPORT NativeImageData : public OHOS::FFI::FFIData {
28 public:
29     NativeImageData();
30     ~NativeImageData() override;
31     int32_t GetHeight() const;
32     int32_t GetWidth() const;
33     std::vector<uint8_t> GetData() const;
34 
35     int32_t width_ = 0;
36     int32_t height_ = 0;
37     std::vector<uint8_t> data;
38 
39     bool GetImageDataSize(double width, double height, int32_t& finalWidth, int32_t& finalHeight);
40 
setX(int32_t x)41     void setX(int32_t x)
42     {
43         x_ = x;
44     }
getX()45     int32_t getX() const
46     {
47         return x_;
48     }
setY(int32_t y)49     void setY(int32_t y)
50     {
51         y_ = y;
52     }
getY()53     int32_t getY() const
54     {
55         return y_;
56     }
setDirtyX(int32_t dirtyX)57     void setDirtyX(int32_t dirtyX)
58     {
59         dirtyX_ = dirtyX;
60     }
getDirtyX()61     int32_t getDirtyX() const
62     {
63         return dirtyX_;
64     }
setDirtyY(int32_t dirtyY)65     void setDirtyY(int32_t dirtyY)
66     {
67         dirtyY_ = dirtyY;
68     }
getDirtyY()69     int32_t getDirtyY() const
70     {
71         return dirtyY_;
72     }
setDirtyWidth(int32_t dirtyWidth)73     void setDirtyWidth(int32_t dirtyWidth)
74     {
75         dirtyWidth_ = dirtyWidth;
76     }
getDirtyWidth()77     int32_t getDirtyWidth() const
78     {
79         return dirtyWidth_;
80     }
setDirtyHeight(int32_t dirtyHeight)81     void setDirtyHeight(int32_t dirtyHeight)
82     {
83         dirtyHeight_ = dirtyHeight;
84     }
getDirtyHeight()85     int32_t getDirtyHeight() const
86     {
87         return dirtyHeight_;
88     }
setData(const std::vector<Color> & data)89     void setData(const std::vector<Color>& data)
90     {
91         data_ = data;
92     }
93 
SetUnit(CanvasUnit unit)94     void SetUnit(CanvasUnit unit)
95     {
96         unit_ = unit;
97     }
98 
GetUnit()99     CanvasUnit GetUnit()
100     {
101         return unit_;
102     }
103 
104     double GetDensity();
105 
106 private:
107     int32_t x_ = 0;
108     int32_t y_ = 0;
109     int32_t dirtyX_ = 0;
110     int32_t dirtyY_ = 0;
111     int32_t dirtyWidth_ = 0;
112     int32_t dirtyHeight_ = 0;
113     std::vector<Color> data_;
114     CanvasUnit unit_ = CanvasUnit::DEFAULT;
115 };
116 
117 } // namespace OHOS::Ace::Framework
118 #endif // FRAMEWORKS_BRIDGE_CJ_FRONTEND_CPP_VIEW_CANVAS_IMAGE_DATA_H
119