diff options
author | Chris Craik <ccraik@google.com> | 2015-07-01 18:10:30 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-07-01 18:10:33 +0000 |
commit | d3ecb3e6f04a0f76c886238af6bef1d10b987a42 (patch) | |
tree | 301913580215be04d3393b47d12339dcdd1db32e /libs | |
parent | a10277e3e4c01e08f53b98eac3c98bf94482b106 (diff) | |
parent | df72b63928cc1492b72ba9a4e99d5e714f93ccc6 (diff) | |
download | frameworks_base-d3ecb3e6f04a0f76c886238af6bef1d10b987a42.zip frameworks_base-d3ecb3e6f04a0f76c886238af6bef1d10b987a42.tar.gz frameworks_base-d3ecb3e6f04a0f76c886238af6bef1d10b987a42.tar.bz2 |
Merge "Switch from fminf/fmaxf to std::min/max" into mnc-dev
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/DisplayListOp.h | 12 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 20 | ||||
-rw-r--r-- | libs/hwui/Patch.cpp | 8 | ||||
-rw-r--r-- | libs/hwui/Rect.h | 33 | ||||
-rw-r--r-- | libs/hwui/TextureCache.cpp | 2 |
5 files changed, 39 insertions, 36 deletions
diff --git a/libs/hwui/DisplayListOp.h b/libs/hwui/DisplayListOp.h index fb2852a..d2bf138 100644 --- a/libs/hwui/DisplayListOp.h +++ b/libs/hwui/DisplayListOp.h @@ -29,6 +29,8 @@ #include "utils/LinearAllocator.h" #include "utils/PaintUtils.h" +#include <algorithm> + #include <SkColor.h> #include <SkPath.h> #include <SkPathOps.h> @@ -184,7 +186,7 @@ public: // TODO: it would be nice if this could take scale into account, but scale isn't stable // since higher levels of the view hierarchy can change scale out from underneath it. - return fmaxf(mPaint->getStrokeWidth(), 1) * 0.5f; + return std::max(mPaint->getStrokeWidth(), 1.0f) * 0.5f; } protected: @@ -235,10 +237,10 @@ public: DrawBoundedOp(const float* points, int count, const SkPaint* paint) : DrawOp(paint), mLocalBounds(points[0], points[1], points[0], points[1]) { for (int i = 2; i < count; i += 2) { - mLocalBounds.left = fminf(mLocalBounds.left, points[i]); - mLocalBounds.right = fmaxf(mLocalBounds.right, points[i]); - mLocalBounds.top = fminf(mLocalBounds.top, points[i + 1]); - mLocalBounds.bottom = fmaxf(mLocalBounds.bottom, points[i + 1]); + mLocalBounds.left = std::min(mLocalBounds.left, points[i]); + mLocalBounds.right = std::max(mLocalBounds.right, points[i]); + mLocalBounds.top = std::min(mLocalBounds.top, points[i + 1]); + mLocalBounds.bottom = std::max(mLocalBounds.bottom, points[i + 1]); } } diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 3d48fa6..87ed84f 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -1626,10 +1626,10 @@ void OpenGLRenderer::drawBitmapMesh(const SkBitmap* bitmap, int meshWidth, int m ColorTextureVertex::set(vertex++, vertices[bx], vertices[by], u1, v1, colors[bx / 2]); ColorTextureVertex::set(vertex++, vertices[cx], vertices[cy], u2, v1, colors[cx / 2]); - left = fminf(left, fminf(vertices[ax], fminf(vertices[bx], vertices[cx]))); - top = fminf(top, fminf(vertices[ay], fminf(vertices[by], vertices[cy]))); - right = fmaxf(right, fmaxf(vertices[ax], fmaxf(vertices[bx], vertices[cx]))); - bottom = fmaxf(bottom, fmaxf(vertices[ay], fmaxf(vertices[by], vertices[cy]))); + left = std::min(left, std::min(vertices[ax], std::min(vertices[bx], vertices[cx]))); + top = std::min(top, std::min(vertices[ay], std::min(vertices[by], vertices[cy]))); + right = std::max(right, std::max(vertices[ax], std::max(vertices[bx], vertices[cx]))); + bottom = std::max(bottom, std::max(vertices[ay], std::max(vertices[by], vertices[cy]))); } } @@ -2127,8 +2127,8 @@ bool OpenGLRenderer::findBestFontTransform(const mat4& transform, SkMatrix* outM float sx, sy; transform.decomposeScale(sx, sy); outMatrix->setScale( - roundf(fmaxf(1.0f, sx)), - roundf(fmaxf(1.0f, sy))); + roundf(std::max(1.0f, sx)), + roundf(std::max(1.0f, sy))); return true; } @@ -2551,10 +2551,10 @@ void OpenGLRenderer::drawColorRects(const float* rects, int count, const SkPaint Vertex::set(vertex++, l, b); Vertex::set(vertex++, r, b); - left = fminf(left, l); - top = fminf(top, t); - right = fmaxf(right, r); - bottom = fmaxf(bottom, b); + left = std::min(left, l); + top = std::min(top, t); + right = std::max(right, r); + bottom = std::max(bottom, b); } if (clip && quickRejectSetupScissor(left, top, right, bottom)) { diff --git a/libs/hwui/Patch.cpp b/libs/hwui/Patch.cpp index f673c6a..f4dd943 100644 --- a/libs/hwui/Patch.cpp +++ b/libs/hwui/Patch.cpp @@ -81,9 +81,9 @@ Patch::Patch(const float bitmapWidth, const float bitmapHeight, } const float xStretchTex = stretchSize; const float fixed = bitmapWidth - stretchSize; - const float xStretch = fmaxf(width - fixed, 0.0f); + const float xStretch = std::max(width - fixed, 0.0f); stretchX = xStretch / xStretchTex; - rescaleX = fixed == 0.0f ? 0.0f : fminf(fmaxf(width, 0.0f) / fixed, 1.0f); + rescaleX = fixed == 0.0f ? 0.0f : std::min(std::max(width, 0.0f) / fixed, 1.0f); } if (yStretchCount > 0) { @@ -93,9 +93,9 @@ Patch::Patch(const float bitmapWidth, const float bitmapHeight, } const float yStretchTex = stretchSize; const float fixed = bitmapHeight - stretchSize; - const float yStretch = fmaxf(height - fixed, 0.0f); + const float yStretch = std::max(height - fixed, 0.0f); stretchY = yStretch / yStretchTex; - rescaleY = fixed == 0.0f ? 0.0f : fminf(fmaxf(height, 0.0f) / fixed, 1.0f); + rescaleY = fixed == 0.0f ? 0.0f : std::min(std::max(height, 0.0f) / fixed, 1.0f); } uint32_t quadCount = 0; diff --git a/libs/hwui/Rect.h b/libs/hwui/Rect.h index c82082f..4c4cd3d 100644 --- a/libs/hwui/Rect.h +++ b/libs/hwui/Rect.h @@ -18,6 +18,7 @@ #define ANDROID_HWUI_RECT_H #include <cmath> +#include <algorithm> #include <SkRect.h> #include <utils/Log.h> @@ -246,17 +247,17 @@ public: } void expandToCoverVertex(float x, float y) { - left = fminf(left, x); - top = fminf(top, y); - right = fmaxf(right, x); - bottom = fmaxf(bottom, y); + left = std::min(left, x); + top = std::min(top, y); + right = std::max(right, x); + bottom = std::max(bottom, y); } void expandToCoverRect(float otherLeft, float otherTop, float otherRight, float otherBottom) { - left = fminf(left, otherLeft); - top = fminf(top, otherTop); - right = fmaxf(right, otherRight); - bottom = fmaxf(bottom, otherBottom); + left = std::min(left, otherLeft); + top = std::min(top, otherTop); + right = std::max(right, otherRight); + bottom = std::max(bottom, otherBottom); } SkRect toSkRect() const { @@ -273,18 +274,18 @@ public: private: void intersectWith(Rect& tmp) const { - tmp.left = fmaxf(left, tmp.left); - tmp.top = fmaxf(top, tmp.top); - tmp.right = fminf(right, tmp.right); - tmp.bottom = fminf(bottom, tmp.bottom); + tmp.left = std::max(left, tmp.left); + tmp.top = std::max(top, tmp.top); + tmp.right = std::min(right, tmp.right); + tmp.bottom = std::min(bottom, tmp.bottom); } Rect intersectWith(float l, float t, float r, float b) const { Rect tmp; - tmp.left = fmaxf(left, l); - tmp.top = fmaxf(top, t); - tmp.right = fminf(right, r); - tmp.bottom = fminf(bottom, b); + tmp.left = std::max(left, l); + tmp.top = std::max(top, t); + tmp.right = std::min(right, r); + tmp.bottom = std::min(bottom, b); return tmp; } diff --git a/libs/hwui/TextureCache.cpp b/libs/hwui/TextureCache.cpp index 5147e98..fe1b7fd 100644 --- a/libs/hwui/TextureCache.cpp +++ b/libs/hwui/TextureCache.cpp @@ -93,7 +93,7 @@ void TextureCache::setMaxSize(uint32_t maxSize) { } void TextureCache::setFlushRate(float flushRate) { - mFlushRate = fmaxf(0.0f, fminf(1.0f, flushRate)); + mFlushRate = std::max(0.0f, std::min(1.0f, flushRate)); } /////////////////////////////////////////////////////////////////////////////// |