diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2023-07-19 20:09:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-19 20:09:49 +0200 |
| commit | 89b87158dbf100e4177f4a010190ba5f80252eb2 (patch) | |
| tree | cacff8d4257c0e4a1f95937c969075df0b07c280 /src/helpers/Region.hpp | |
| parent | ce9896204a2ab1eb4f8960d44b876cbc9d0955ac (diff) | |
internal: Wrap regions (#2750)
Diffstat (limited to 'src/helpers/Region.hpp')
| -rw-r--r-- | src/helpers/Region.hpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/helpers/Region.hpp b/src/helpers/Region.hpp new file mode 100644 index 00000000..5c700fa5 --- /dev/null +++ b/src/helpers/Region.hpp @@ -0,0 +1,53 @@ +#pragma once +#include <pixman.h> +#include <vector> +#include "Vector2D.hpp" + +struct wlr_box; + +class CRegion { + public: + /* Create an empty region */ + CRegion(); + /* Create from a reference. Copies, does not own. */ + CRegion(pixman_region32_t* ref); + /* Create from a box */ + CRegion(double x, double y, double w, double h); + /* Create from a wlr_box */ + CRegion(wlr_box* box); + + CRegion(const CRegion&); + CRegion(CRegion&&); + + ~CRegion(); + + CRegion& operator=(CRegion&& other) { + pixman_region32_copy(&m_rRegion, other.pixman()); + return *this; + } + + CRegion& operator=(CRegion& other) { + pixman_region32_copy(&m_rRegion, other.pixman()); + return *this; + } + + CRegion& clear(); + CRegion& set(const CRegion& other); + CRegion& add(const CRegion& other); + CRegion& add(double x, double y, double w, double h); + CRegion& subtract(const CRegion& other); + CRegion& intersect(const CRegion& other); + CRegion& intersect(double x, double y, double w, double h); + CRegion& translate(const Vector2D& vec); + CRegion& invert(pixman_box32_t* box); + bool empty(); + + std::vector<pixman_box32_t> getRects() const; + + pixman_region32_t* pixman() { + return &m_rRegion; + } + + private: + pixman_region32_t m_rRegion; +};
\ No newline at end of file |
