target_sources(lottie-player
PRIVATE
+ "${CMAKE_CURRENT_LIST_DIR}/vrect.cpp"
"${CMAKE_CURRENT_LIST_DIR}/vdasher.cpp"
"${CMAKE_CURRENT_LIST_DIR}/vbrush.cpp"
"${CMAKE_CURRENT_LIST_DIR}/vbitmap.cpp"
source_file += files('vdrawhelper_sse2.cpp')
source_file += files('vdrawable.cpp')
-
+source_file += files('vrect.cpp')
source_file += files('vrle.cpp')
source_file += files('vpath.cpp')
source_file += files('vpathmesure.cpp')
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+#include "vrect.h"
+
+VRect VRect::operator&(const VRect &r) const
+{
+ if (empty())
+ return VRect();
+
+ int l1 = x1;
+ int r1 = x1;
+ if (x2 - x1 + 1 < 0)
+ l1 = x2;
+ else
+ r1 = x2;
+
+ int l2 = r.x1;
+ int r2 = r.x1;
+ if (r.x2 - r.x1 + 1 < 0)
+ l2 = r.x2;
+ else
+ r2 = r.x2;
+
+ if (l1 > r2 || l2 > r1)
+ return VRect();
+
+ int t1 = y1;
+ int b1 = y1;
+ if (y2 - y1 + 1 < 0)
+ t1 = y2;
+ else
+ b1 = y2;
+
+ int t2 = r.y1;
+ int b2 = r.y1;
+ if (r.y2 - r.y1 + 1 < 0)
+ t2 = r.y2;
+ else
+ b2 = r.y2;
+
+ if (t1 > b2 || t2 > b1)
+ return VRect();
+
+ VRect tmp;
+ tmp.x1 = std::max(l1, l2);
+ tmp.x2 = std::min(r1, r2);
+ tmp.y1 = std::max(t1, t2);
+ tmp.y2 = std::min(b1, b2);
+ return tmp;
+}
V_CONSTEXPR int height() const {return y2-y1;}
V_CONSTEXPR int x() const {return x1;}
V_CONSTEXPR int y() const {return y1;}
+ VSize size() const {return {width(), height()};}
void setLeft(int l) { x1 = l; }
void setTop(int t) { y1 = t; }
void setRight(int r) { x2 = r; }
const VRect &) noexcept;
friend VDebug & operator<<(VDebug &os, const VRect &o);
+ VRect intersected(const VRect &r) const;
+ VRect operator&(const VRect &r) const;
+
private:
int x1{0};
int y1{0};
int y2{0};
};
+inline VRect VRect::intersected(const VRect &r) const
+{
+ return *this & r;
+}
+
inline bool VRect::intersects(const VRect &r)
{
return (right() > r.left() && left() < r.right() && bottom() > r.top() &&