Remove all usage of fmin and fmax

bug:22208220

Removes needless call, and upconversion to doubles in multiple places.

Change-Id: I1b949fa5f206446ac34de800154c0147d6bd8034
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index 9664f58..35051b7 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -521,10 +521,10 @@
     appendMeshQuadNoClip(x1, y1, u1, v1, x2, y2, u2, v2, x3, y3, u3, v3, x4, y4, u4, v4, texture);
 
     if (mBounds) {
-        mBounds->left = fmin(mBounds->left, x1);
-        mBounds->top = fmin(mBounds->top, y3);
-        mBounds->right = fmax(mBounds->right, x3);
-        mBounds->bottom = fmax(mBounds->bottom, y1);
+        mBounds->left = std::min(mBounds->left, x1);
+        mBounds->top = std::min(mBounds->top, y3);
+        mBounds->right = std::max(mBounds->right, x3);
+        mBounds->bottom = std::max(mBounds->bottom, y1);
     }
 
     if (mCurrentCacheTexture->endOfMesh()) {
@@ -539,10 +539,10 @@
     appendMeshQuadNoClip(x1, y1, u1, v1, x2, y2, u2, v2, x3, y3, u3, v3, x4, y4, u4, v4, texture);
 
     if (mBounds) {
-        mBounds->left = fmin(mBounds->left, fmin(x1, fmin(x2, fmin(x3, x4))));
-        mBounds->top = fmin(mBounds->top, fmin(y1, fmin(y2, fmin(y3, y4))));
-        mBounds->right = fmax(mBounds->right, fmax(x1, fmax(x2, fmax(x3, x4))));
-        mBounds->bottom = fmax(mBounds->bottom, fmax(y1, fmax(y2, fmax(y3, y4))));
+        mBounds->left = std::min(mBounds->left, std::min(x1, std::min(x2, std::min(x3, x4))));
+        mBounds->top = std::min(mBounds->top, std::min(y1, std::min(y2, std::min(y3, y4))));
+        mBounds->right = std::max(mBounds->right, std::max(x1, std::max(x2, std::max(x3, x4))));
+        mBounds->bottom = std::max(mBounds->bottom, std::max(y1, std::max(y2, std::max(y3, y4))));
     }
 
     if (mCurrentCacheTexture->endOfMesh()) {
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 87ed84f..ed2a4db 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -1670,10 +1670,10 @@
     if (!texture) return;
     const AutoTexture autoCleanup(texture);
 
-    Rect uv(fmax(0.0f, src.left / texture->width),
-            fmax(0.0f, src.top / texture->height),
-            fmin(1.0f, src.right / texture->width),
-            fmin(1.0f, src.bottom / texture->height));
+    Rect uv(std::max(0.0f, src.left / texture->width),
+            std::max(0.0f, src.top / texture->height),
+            std::min(1.0f, src.right / texture->width),
+            std::min(1.0f, src.bottom / texture->height));
 
     const int textureFillFlags = (bitmap->colorType() == kAlpha_8_SkColorType)
             ? TextureFillFlags::IsAlphaMaskTexture : TextureFillFlags::None;
@@ -2450,7 +2450,7 @@
 
         if (CC_LIKELY(underlineWidth > 0.0f)) {
             const float textSize = paintCopy.getTextSize();
-            const float strokeWidth = fmax(textSize * kStdUnderline_Thickness, 1.0f);
+            const float strokeWidth = std::max(textSize * kStdUnderline_Thickness, 1.0f);
 
             const float left = x;
             float top = 0.0f;
diff --git a/libs/hwui/Patch.cpp b/libs/hwui/Patch.cpp
index f4dd943..6a7dfb3 100644
--- a/libs/hwui/Patch.cpp
+++ b/libs/hwui/Patch.cpp
@@ -119,7 +119,7 @@
         }
 
         float vOffset = y1 == y2 ? 0.0f : 0.5 - (0.5 * segment / (y2 - y1));
-        float v2 = fmax(0.0f, stepY - vOffset) / bitmapHeight;
+        float v2 = std::max(0.0f, stepY - vOffset) / bitmapHeight;
         v1 += vOffset / bitmapHeight;
 
         if (stepY > 0.0f) {
@@ -167,7 +167,7 @@
         }
 
         float uOffset = x1 == x2 ? 0.0f : 0.5 - (0.5 * segment / (x2 - x1));
-        float u2 = fmax(0.0f, stepX - uOffset) / bitmapWidth;
+        float u2 = std::max(0.0f, stepX - uOffset) / bitmapWidth;
         u1 += uOffset / bitmapWidth;
 
         if (stepX > 0.0f) {
diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp
index e466604..3af640f 100644
--- a/libs/hwui/PathCache.cpp
+++ b/libs/hwui/PathCache.cpp
@@ -91,13 +91,13 @@
 
 void PathCache::computeBounds(const SkRect& bounds, const SkPaint* paint,
         float& left, float& top, float& offset, uint32_t& width, uint32_t& height) {
-    const float pathWidth = fmax(bounds.width(), 1.0f);
-    const float pathHeight = fmax(bounds.height(), 1.0f);
+    const float pathWidth = std::max(bounds.width(), 1.0f);
+    const float pathHeight = std::max(bounds.height(), 1.0f);
 
     left = bounds.fLeft;
     top = bounds.fTop;
 
-    offset = (int) floorf(fmax(paint->getStrokeWidth(), 1.0f) * 1.5f + 0.5f);
+    offset = (int) floorf(std::max(paint->getStrokeWidth(), 1.0f) * 1.5f + 0.5f);
 
     width = uint32_t(pathWidth + offset * 2.0 + 0.5);
     height = uint32_t(pathHeight + offset * 2.0 + 0.5);
diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp
index 7dbe3b7..2e63793 100644
--- a/libs/hwui/Properties.cpp
+++ b/libs/hwui/Properties.cpp
@@ -17,7 +17,7 @@
 
 #include "Debug.h"
 
-#include <cmath>
+#include <algorithm>
 #include <cutils/log.h>
 
 namespace android {
@@ -117,19 +117,19 @@
         ALOGD("profile bars %s", sDisableProfileBars ? "disabled" : "enabled");
         return;
     } else if (!strcmp(name, "ambientRatio")) {
-        overrideAmbientRatio = fmin(fmax(atof(value), 0.0), 10.0);
+        overrideAmbientRatio = std::min(std::max(atof(value), 0.0), 10.0);
         ALOGD("ambientRatio = %.2f", overrideAmbientRatio);
         return;
     } else if (!strcmp(name, "lightRadius")) {
-        overrideLightRadius = fmin(fmax(atof(value), 0.0), 3000.0);
+        overrideLightRadius = std::min(std::max(atof(value), 0.0), 3000.0);
         ALOGD("lightRadius = %.2f", overrideLightRadius);
         return;
     } else if (!strcmp(name, "lightPosY")) {
-        overrideLightPosY = fmin(fmax(atof(value), 0.0), 3000.0);
+        overrideLightPosY = std::min(std::max(atof(value), 0.0), 3000.0);
         ALOGD("lightPos Y = %.2f", overrideLightPosY);
         return;
     } else if (!strcmp(name, "lightPosZ")) {
-        overrideLightPosZ = fmin(fmax(atof(value), 0.0), 3000.0);
+        overrideLightPosZ = std::min(std::max(atof(value), 0.0), 3000.0);
         ALOGD("lightPos Z = %.2f", overrideLightPosZ);
         return;
     } else if (!strcmp(name, "ambientShadowStrength")) {
diff --git a/libs/hwui/TessellationCache.cpp b/libs/hwui/TessellationCache.cpp
index 9df1f0d..17cb3a7 100644
--- a/libs/hwui/TessellationCache.cpp
+++ b/libs/hwui/TessellationCache.cpp
@@ -244,8 +244,8 @@
         const Vertex& point2d = casterVertices2d[i];
         casterPolygon[i] = (Vector3){point2d.x, point2d.y, 0};
         mapPointFakeZ(casterPolygon[i], casterTransformXY, casterTransformZ);
-        minZ = fmin(minZ, casterPolygon[i].z);
-        maxZ = fmax(maxZ, casterPolygon[i].z);
+        minZ = std::min(minZ, casterPolygon[i].z);
+        maxZ = std::max(maxZ, casterPolygon[i].z);
     }
 
     // map the centroid of the caster into 3d
diff --git a/libs/hwui/font/CacheTexture.cpp b/libs/hwui/font/CacheTexture.cpp
index 845cf30..d2685da 100644
--- a/libs/hwui/font/CacheTexture.cpp
+++ b/libs/hwui/font/CacheTexture.cpp
@@ -314,7 +314,7 @@
 #endif
             }
 
-            if (cacheBlock->mHeight < fmin(glyphH, glyphW)) {
+            if (cacheBlock->mHeight < std::min(glyphH, glyphW)) {
                 // If remaining space in this block is too small to be useful, remove it
                 mCacheBlocks = CacheBlock::removeBlock(mCacheBlocks, cacheBlock);
             }