Merge "Remove MathUtils::min/max"
This commit is contained in:
@@ -52,14 +52,14 @@
|
||||
// If this is set to negative value, then all the edge will be tessellated.
|
||||
#define ALPHA_THRESHOLD (0.1f / 255.0f)
|
||||
|
||||
#include <math.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include "AmbientShadow.h"
|
||||
|
||||
#include "ShadowTessellator.h"
|
||||
#include "Vertex.h"
|
||||
#include "VertexBuffer.h"
|
||||
#include "utils/MathUtils.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utils/Log.h>
|
||||
|
||||
namespace android {
|
||||
namespace uirenderer {
|
||||
@@ -78,7 +78,7 @@ inline Vector2 getNormalFromVertices(const Vector3* vertices, int current, int n
|
||||
// The input z value will be converted to be non-negative inside.
|
||||
// The output must be ranged from 0 to 1.
|
||||
inline float getAlphaFromFactoredZ(float factoredZ) {
|
||||
return 1.0 / (1 + MathUtils::max(factoredZ, 0.0f));
|
||||
return 1.0 / (1 + std::max(factoredZ, 0.0f));
|
||||
}
|
||||
|
||||
// The shader is using gaussian function e^-(1-x)*(1-x)*4, therefore, we transform
|
||||
|
||||
@@ -26,14 +26,12 @@
|
||||
#include "Rect.h"
|
||||
#include "renderstate/RenderState.h"
|
||||
#include "utils/Blur.h"
|
||||
#include "utils/MathUtils.h"
|
||||
#include "utils/Timing.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cutils/properties.h>
|
||||
#include <SkGlyph.h>
|
||||
#include <SkUtils.h>
|
||||
|
||||
#include <cutils/properties.h>
|
||||
|
||||
#include <utils/Log.h>
|
||||
|
||||
#ifdef ANDROID_ENABLE_RENDERSCRIPT
|
||||
@@ -118,10 +116,10 @@ FontRenderer::FontRenderer()
|
||||
|
||||
uint32_t maxTextureSize = (uint32_t) Caches::getInstance().maxTextureSize;
|
||||
|
||||
mSmallCacheWidth = MathUtils::min(mSmallCacheWidth, maxTextureSize);
|
||||
mSmallCacheHeight = MathUtils::min(mSmallCacheHeight, maxTextureSize);
|
||||
mLargeCacheWidth = MathUtils::min(mLargeCacheWidth, maxTextureSize);
|
||||
mLargeCacheHeight = MathUtils::min(mLargeCacheHeight, maxTextureSize);
|
||||
mSmallCacheWidth = std::min(mSmallCacheWidth, maxTextureSize);
|
||||
mSmallCacheHeight = std::min(mSmallCacheHeight, maxTextureSize);
|
||||
mLargeCacheWidth = std::min(mLargeCacheWidth, maxTextureSize);
|
||||
mLargeCacheHeight = std::min(mLargeCacheHeight, maxTextureSize);
|
||||
|
||||
if (sLogFontRendererCreate) {
|
||||
INIT_LOGD(" Text cache sizes, in pixels: %i x %i, %i x %i, %i x %i, %i x %i",
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
#include "Interpolator.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cutils/log.h>
|
||||
|
||||
#include "utils/MathUtils.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cutils/log.h>
|
||||
|
||||
namespace android {
|
||||
namespace uirenderer {
|
||||
|
||||
@@ -106,7 +106,7 @@ float LUTInterpolator::interpolate(float input) {
|
||||
weight = modff(lutpos, &ipart);
|
||||
|
||||
int i1 = (int) ipart;
|
||||
int i2 = MathUtils::min(i1 + 1, (int) mSize - 1);
|
||||
int i2 = std::min(i1 + 1, (int) mSize - 1);
|
||||
|
||||
LOG_ALWAYS_FATAL_IF(i1 < 0 || i2 < 0, "negatives in interpolation!"
|
||||
" i1=%d, i2=%d, input=%f, lutpos=%f, size=%zu, values=%p, ipart=%f, weight=%f",
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <utils/Log.h>
|
||||
#include "Patch.h"
|
||||
|
||||
#include "Caches.h"
|
||||
#include "Patch.h"
|
||||
#include "Properties.h"
|
||||
#include "UvMapper.h"
|
||||
#include "utils/MathUtils.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utils/Log.h>
|
||||
|
||||
namespace android {
|
||||
namespace uirenderer {
|
||||
|
||||
@@ -189,10 +189,10 @@ void Patch::generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, f
|
||||
const uint32_t oldQuadCount = quadCount;
|
||||
quadCount++;
|
||||
|
||||
x1 = MathUtils::max(x1, 0.0f);
|
||||
x2 = MathUtils::max(x2, 0.0f);
|
||||
y1 = MathUtils::max(y1, 0.0f);
|
||||
y2 = MathUtils::max(y2, 0.0f);
|
||||
x1 = std::max(x1, 0.0f);
|
||||
x2 = std::max(x2, 0.0f);
|
||||
y1 = std::max(y1, 0.0f);
|
||||
y2 = std::max(y2, 0.0f);
|
||||
|
||||
// Skip degenerate and transparent (empty) quads
|
||||
if ((mColors[oldQuadCount] == 0) || x1 >= x2 || y1 >= y2) {
|
||||
|
||||
@@ -32,6 +32,15 @@
|
||||
#define DEBUG_DUMP_BUFFER()
|
||||
#endif
|
||||
|
||||
#include "PathTessellator.h"
|
||||
|
||||
#include "Matrix.h"
|
||||
#include "Vector.h"
|
||||
#include "Vertex.h"
|
||||
#include "utils/MathUtils.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <SkPath.h>
|
||||
#include <SkPaint.h>
|
||||
#include <SkPoint.h>
|
||||
@@ -44,12 +53,6 @@
|
||||
#include <utils/Log.h>
|
||||
#include <utils/Trace.h>
|
||||
|
||||
#include "PathTessellator.h"
|
||||
#include "Matrix.h"
|
||||
#include "Vector.h"
|
||||
#include "Vertex.h"
|
||||
#include "utils/MathUtils.h"
|
||||
|
||||
namespace android {
|
||||
namespace uirenderer {
|
||||
|
||||
@@ -152,7 +155,7 @@ public:
|
||||
// always use 2 points for hairline
|
||||
if (halfStrokeWidth == 0.0f) return 2;
|
||||
|
||||
float threshold = MathUtils::min(inverseScaleX, inverseScaleY) * ROUND_CAP_THRESH;
|
||||
float threshold = std::min(inverseScaleX, inverseScaleY) * ROUND_CAP_THRESH;
|
||||
return MathUtils::divisionsNeededToApproximateArc(halfStrokeWidth, PI, threshold);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -22,8 +22,12 @@
|
||||
#include "Vertex.h"
|
||||
#include "VertexBuffer.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
class SkPath;
|
||||
class SkPaint;
|
||||
|
||||
namespace android {
|
||||
namespace uirenderer {
|
||||
|
||||
@@ -38,7 +42,7 @@ struct PathApproximationInfo {
|
||||
: thresholdSquared(pixelThreshold * pixelThreshold)
|
||||
, sqrInvScaleX(invScaleX * invScaleX)
|
||||
, sqrInvScaleY(invScaleY * invScaleY)
|
||||
, thresholdForConicQuads(pixelThreshold * MathUtils::min(invScaleX, invScaleY) / 2.0f) {
|
||||
, thresholdForConicQuads(pixelThreshold * std::min(invScaleX, invScaleY) / 2.0f) {
|
||||
};
|
||||
|
||||
const float thresholdSquared;
|
||||
|
||||
@@ -46,17 +46,18 @@
|
||||
#define TRANSFORMED_PENUMBRA_ALPHA 1.0f
|
||||
#define TRANSFORMED_UMBRA_ALPHA 0.0f
|
||||
|
||||
#include "SpotShadow.h"
|
||||
|
||||
#include "ShadowTessellator.h"
|
||||
#include "Vertex.h"
|
||||
#include "VertexBuffer.h"
|
||||
#include "utils/MathUtils.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include "ShadowTessellator.h"
|
||||
#include "SpotShadow.h"
|
||||
#include "Vertex.h"
|
||||
#include "VertexBuffer.h"
|
||||
#include "utils/MathUtils.h"
|
||||
|
||||
// TODO: After we settle down the new algorithm, we can remove the old one and
|
||||
// its utility functions.
|
||||
// Right now, we still need to keep it for comparison purpose and future expansion.
|
||||
@@ -543,7 +544,7 @@ void SpotShadow::createSpotShadow(bool isCasterOpaque, const Vector3& lightCente
|
||||
}
|
||||
|
||||
float ratioVI = outlineData[i].radius / distOutline;
|
||||
minRaitoVI = MathUtils::min(minRaitoVI, ratioVI);
|
||||
minRaitoVI = std::min(minRaitoVI, ratioVI);
|
||||
if (ratioVI >= (1 - FAKE_UMBRA_SIZE_RATIO)) {
|
||||
ratioVI = (1 - FAKE_UMBRA_SIZE_RATIO);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#ifndef ANDROID_HWUI_VERTEX_BUFFER_H
|
||||
#define ANDROID_HWUI_VERTEX_BUFFER_H
|
||||
|
||||
#include "utils/MathUtils.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace android {
|
||||
namespace uirenderer {
|
||||
@@ -129,10 +129,10 @@ public:
|
||||
unsigned int getSize() const { return mByteCount; }
|
||||
unsigned int getIndexCount() const { return mIndexCount; }
|
||||
void updateIndexCount(unsigned int newCount) {
|
||||
mIndexCount = MathUtils::min(newCount, mAllocatedIndexCount);
|
||||
mIndexCount = std::min(newCount, mAllocatedIndexCount);
|
||||
}
|
||||
void updateVertexCount(unsigned int newCount) {
|
||||
mVertexCount = MathUtils::min(newCount, mAllocatedVertexCount);
|
||||
mVertexCount = std::min(newCount, mAllocatedVertexCount);
|
||||
}
|
||||
MeshFeatureFlags getMeshFeatureFlags() const { return mMeshFeatureFlags; }
|
||||
void setMeshFeatureFlags(int flags) {
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "renderthread/EglManager.h"
|
||||
#include "utils/GLUtils.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace android {
|
||||
namespace uirenderer {
|
||||
|
||||
@@ -320,7 +322,7 @@ void RenderState::render(const Glop& glop) {
|
||||
GLsizei elementsCount = mesh.elementCount;
|
||||
const GLbyte* vertexData = static_cast<const GLbyte*>(vertices.position);
|
||||
while (elementsCount > 0) {
|
||||
GLsizei drawCount = MathUtils::min(elementsCount, (GLsizei) kMaxNumberOfQuads * 6);
|
||||
GLsizei drawCount = std::min(elementsCount, (GLsizei) kMaxNumberOfQuads * 6);
|
||||
|
||||
// rebind pointers without forcing, since initial bind handled above
|
||||
meshState().bindPositionVertexPointer(false, vertexData, vertices.stride);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#ifndef MATHUTILS_H
|
||||
#define MATHUTILS_H
|
||||
|
||||
#include <algorithm>
|
||||
#include <math.h>
|
||||
|
||||
namespace android {
|
||||
@@ -81,19 +82,9 @@ public:
|
||||
return isZero(valueA - valueB);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static inline T max(T a, T b) {
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static inline T min(T a, T b) {
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static inline T clamp(T a, T minValue, T maxValue) {
|
||||
return min(max(a, minValue), maxValue);
|
||||
return std::min(std::max(a, minValue), maxValue);
|
||||
}
|
||||
|
||||
inline static float lerp(float v1, float v2, float t) {
|
||||
|
||||
Reference in New Issue
Block a user