sw_engine: Replace non-portable min/max with tvgMath.h macros 90/288990/1
authorRémi Verschelde <rverschelde@gmail.com>
Wed, 19 Jan 2022 09:59:34 +0000 (10:59 +0100)
committerMichal Szczecinski <mihashco89@gmail.com>
Mon, 27 Feb 2023 07:37:25 +0000 (08:37 +0100)
This would fail building with Visual Studio 2017, at least downstream in Godot
where we undefine old Windows compilers' non-standard `min`/`max` macros (see
`minmax.h`/`NOMINMAX`).

Change-Id: I593db53fb75b8eaac98f578fb49fa8f923cb7fb9

AUTHORS
src/lib/sw_engine/tvgSwRenderer.cpp
src/lib/tvgMath.h

diff --git a/AUTHORS b/AUTHORS
index 6605723..ec06c49 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -13,3 +13,5 @@ Pankaj Kumar <pankaj.m1@samsung.com>
 Patryk Kaczmarek <patryk.k@partner.samsung.com>
 Michal Maciola <m.maciola@samsung.com>
 Peter Vullings <peter@projectitis.com>
+K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>
+Rémi Verschelde <rverschelde@gmail.com>
index f63cece..49a4b5e 100644 (file)
@@ -23,6 +23,7 @@
 #include "tvgSwCommon.h"
 #include "tvgTaskScheduler.h"
 #include "tvgSwRenderer.h"
+#include "tvgMath.h"
 
 /************************************************************************/
 /* Internal Class Implementation                                        */
@@ -594,10 +595,10 @@ void* SwRenderer::prepareCommon(SwTask* task, const RenderTransform* transform,
     task->surface = surface;
     task->mpool = mpool;
     task->flags = flags;
-    task->bbox.min.x = max(static_cast<SwCoord>(0), static_cast<SwCoord>(vport.x));
-    task->bbox.min.y = max(static_cast<SwCoord>(0), static_cast<SwCoord>(vport.y));
-    task->bbox.max.x = min(static_cast<SwCoord>(surface->w), static_cast<SwCoord>(vport.x + vport.w));
-    task->bbox.max.y = min(static_cast<SwCoord>(surface->h), static_cast<SwCoord>(vport.y + vport.h));
+    task->bbox.min.x = mathMax(static_cast<SwCoord>(0), static_cast<SwCoord>(vport.x));
+    task->bbox.min.y = mathMax(static_cast<SwCoord>(0), static_cast<SwCoord>(vport.y));
+    task->bbox.max.x = mathMin(static_cast<SwCoord>(surface->w), static_cast<SwCoord>(vport.x + vport.w));
+    task->bbox.max.y = mathMin(static_cast<SwCoord>(surface->h), static_cast<SwCoord>(vport.y + vport.h));
 
     if (!task->pushed) {
         task->pushed = true;
index da93199..d4d3ad9 100644 (file)
 #include "tvgCommon.h"
 
 
+#define mathMin(x, y) (((x) < (y)) ? (x) : (y))
+#define mathMax(x, y) (((x) > (y)) ? (x) : (y))
+
+
 static inline bool mathZero(float a)
 {
     return (fabsf(a) < FLT_EPSILON) ? true : false;
@@ -154,4 +158,4 @@ static inline Matrix mathMultiply(const Matrix* lhs, const Matrix* rhs)
 }
 
 
-#endif //_TVG_MATH_H_
\ No newline at end of file
+#endif //_TVG_MATH_H_