• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_CANVAS_IMAGE_DATA_H
17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_CANVAS_IMAGE_DATA_H
18 
19 #include "base/memory/referenced.h"
20 #include "bridge/declarative_frontend/engine/bindings_defines.h"
21 #include "bridge/declarative_frontend/jsview/js_view_common_def.h"
22 
23 namespace OHOS::Ace::Framework {
24 
25 class JSCanvasImageData : public Referenced {
26 public:
27     JSCanvasImageData() = default;
28     ~JSCanvasImageData() override = default;
29 
30     static void JSBind(BindingTarget globalObj);
31     static void Constructor(const JSCallbackInfo& args);
32     static void Destructor(JSCanvasImageData* controller);
33 
34     void JsGetWidth(const JSCallbackInfo& info);
35     void JsGetHeight(const JSCallbackInfo& info);
36     void JsGetData(const JSCallbackInfo& info);
37     void JsSetWidth(const JSCallbackInfo& info);
38     void JsSetHeight(const JSCallbackInfo& info);
39     void JsSetData(const JSCallbackInfo& info);
40 
41     int32_t width_ = 0;
42     int32_t height_ = 0;
43     JSRef<JSArray> colorArray_;
44 
setX(int32_t x)45     void setX(int32_t x)
46     {
47         x_ = x;
48     }
getX()49     int32_t getX() const
50     {
51         return x_;
52     }
setY(int32_t y)53     void setY(int32_t y)
54     {
55         y_ = y;
56     }
getY()57     int32_t getY() const
58     {
59         return y_;
60     }
setDirtyX(int32_t dirtyX)61     void setDirtyX(int32_t dirtyX)
62     {
63         dirtyX_ = dirtyX;
64     }
getDirtyX()65     int32_t getDirtyX() const
66     {
67         return dirtyX_;
68     }
setDirtyY(int32_t dirtyY)69     void setDirtyY(int32_t dirtyY)
70     {
71         dirtyY_ = dirtyY;
72     }
getDirtyY()73     int32_t getDirtyY() const
74     {
75         return dirtyY_;
76     }
setDirtyWidth(int32_t dirtyWidth)77     void setDirtyWidth(int32_t dirtyWidth)
78     {
79         dirtyWidth_ = dirtyWidth;
80     }
getDirtyWidth()81     int32_t getDirtyWidth() const
82     {
83         return dirtyWidth_;
84     }
setDirtyHeight(int32_t dirtyHeight)85     void setDirtyHeight(int32_t dirtyHeight)
86     {
87         dirtyHeight_ = dirtyHeight;
88     }
getDirtyHeight()89     int32_t getDirtyHeight() const
90     {
91         return dirtyHeight_;
92     }
setData(const std::vector<Color> & data)93     void setData(const std::vector<Color>& data)
94     {
95         data_ = data;
96     }
97 
98 private:
99     int32_t x_ = 0;
100     int32_t y_ = 0;
101     int32_t dirtyX_ = 0;
102     int32_t dirtyY_ = 0;
103     int32_t dirtyWidth_ = 0;
104     int32_t dirtyHeight_ = 0;
105     std::vector<Color> data_;
106 
107     ACE_DISALLOW_COPY_AND_MOVE(JSCanvasImageData);
108 };
109 
110 } // namespace OHOS::Ace::Framework
111 
112 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_CANVAS_IMAGE_DATA_H