Remove two macros
This is colliding with ag/13519705 and causing
build issues. So replace the macros with constexpr's which are
better
Bug: 179047472
Test: make
Change-Id: Icf7c38077ef608ec97e737d47d3d6c25246190bf
diff --git a/libs/hwui/Layer.cpp b/libs/hwui/Layer.cpp
index ca2ada9..b14ade9 100644
--- a/libs/hwui/Layer.cpp
+++ b/libs/hwui/Layer.cpp
@@ -54,7 +54,7 @@
}
static inline SkScalar isIntegerAligned(SkScalar x) {
- return fabsf(roundf(x) - x) <= NON_ZERO_EPSILON;
+ return MathUtils::isZero(roundf(x) - x);
}
// Disable filtering when there is no scaling in screen coordinates and the corners have the same
diff --git a/libs/hwui/pipeline/skia/LayerDrawable.cpp b/libs/hwui/pipeline/skia/LayerDrawable.cpp
index 34df5dd..471a7f7 100644
--- a/libs/hwui/pipeline/skia/LayerDrawable.cpp
+++ b/libs/hwui/pipeline/skia/LayerDrawable.cpp
@@ -34,7 +34,7 @@
}
static inline SkScalar isIntegerAligned(SkScalar x) {
- return fabsf(roundf(x) - x) <= NON_ZERO_EPSILON;
+ return MathUtils::isZero(roundf(x) - x);
}
// Disable filtering when there is no scaling in screen coordinates and the corners have the same
diff --git a/libs/hwui/pipeline/skia/ReorderBarrierDrawables.cpp b/libs/hwui/pipeline/skia/ReorderBarrierDrawables.cpp
index 3b8caeb..7cfccb5 100644
--- a/libs/hwui/pipeline/skia/ReorderBarrierDrawables.cpp
+++ b/libs/hwui/pipeline/skia/ReorderBarrierDrawables.cpp
@@ -52,7 +52,7 @@
RenderNodeDrawable* childNode = mChildren[drawIndex];
SkASSERT(childNode);
const float casterZ = childNode->getNodeProperties().getZ();
- if (casterZ >= -NON_ZERO_EPSILON) { // draw only children with negative Z
+ if (casterZ >= -MathUtils::NON_ZERO_EPSILON) { // draw only children with negative Z
return;
}
SkAutoCanvasRestore acr(canvas, true);
@@ -86,7 +86,7 @@
const size_t endIndex = zChildren.size();
while (drawIndex < endIndex // draw only children with positive Z
- && zChildren[drawIndex]->getNodeProperties().getZ() <= NON_ZERO_EPSILON)
+ && zChildren[drawIndex]->getNodeProperties().getZ() <= MathUtils::NON_ZERO_EPSILON)
drawIndex++;
size_t shadowIndex = drawIndex;
diff --git a/libs/hwui/utils/MathUtils.h b/libs/hwui/utils/MathUtils.h
index 62bf39c..1d3f9d7 100644
--- a/libs/hwui/utils/MathUtils.h
+++ b/libs/hwui/utils/MathUtils.h
@@ -22,11 +22,11 @@
namespace android {
namespace uirenderer {
-#define NON_ZERO_EPSILON (0.001f)
-#define ALPHA_EPSILON (0.001f)
-
class MathUtils {
public:
+ static constexpr float NON_ZERO_EPSILON = 0.001f;
+ static constexpr float ALPHA_EPSILON = 0.001f;
+
/**
* Check for floats that are close enough to zero.
*/