-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathCanvas.h
More file actions
57 lines (40 loc) · 1.54 KB
/
Canvas.h
File metadata and controls
57 lines (40 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include <memory>
#include <string>
#include "Unions.h"
#include "webgpu/webgpu_cpp.h"
#include "RNFHybridObject.h"
namespace rnwgpu {
namespace m = margelo;
class Canvas : public m::HybridObject {
public:
explicit Canvas(void *surface, const int width, const int height)
: HybridObject("Canvas"), _surface(surface), _width(width),
_height(height), _clientWidth(width), _clientHeight(height) {}
int getWidth() { return _width; }
int getHeight() { return _height; }
void setWidth(const int width) { _width = width; }
void setHeight(const int height) { _height = height; }
int getClientWidth() { return _clientWidth; }
int getClientHeight() { return _clientHeight; }
void setClientWidth(const int width) { _clientWidth = width; }
void setClientHeight(const int height) { _clientHeight = height; }
void *getSurface() { return _surface; }
void loadHybridMethods() override {
registerHybridGetter("surface", &Canvas::getSurface, this);
registerHybridGetter("width", &Canvas::getWidth, this);
registerHybridGetter("height", &Canvas::getHeight, this);
registerHybridGetter("clientWidth", &Canvas::getClientWidth, this);
registerHybridGetter("clientHeight", &Canvas::getClientHeight, this);
registerHybridSetter("width", &Canvas::setWidth, this);
registerHybridSetter("height", &Canvas::setHeight, this);
}
size_t getMemoryPressure() override { return sizeof(Canvas); }
private:
void *_surface;
int _width;
int _height;
int _clientWidth;
int _clientHeight;
};
} // namespace rnwgpu