Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d3ecb3e6 authored by Chris Craik's avatar Chris Craik Committed by Android (Google) Code Review
Browse files

Merge "Switch from fminf/fmaxf to std::min/max" into mnc-dev

parents a10277e3 df72b639
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -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]);
        }
    }

+10 −10
Original line number Diff line number Diff line
@@ -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)) {
+4 −4
Original line number Diff line number Diff line
@@ -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;
+17 −16
Original line number Diff line number Diff line
@@ -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;
    }

+1 −1
Original line number Diff line number Diff line
@@ -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));
}

///////////////////////////////////////////////////////////////////////////////