mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 04:41:11 +00:00
Bug 1929268 - Use std::clamp instead of min/max chain in image/ r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D227979
This commit is contained in:
parent
4c6d17f5dd
commit
08bb52d73f
@ -286,7 +286,7 @@ void Downscaler::DownscaleInputLine() {
|
||||
|
||||
// Shift the buffer. We're just moving pointers here, so this is cheap.
|
||||
mLinesInBuffer -= diff;
|
||||
mLinesInBuffer = std::min(std::max(mLinesInBuffer, 0), mWindowCapacity);
|
||||
mLinesInBuffer = std::clamp(mLinesInBuffer, 0, mWindowCapacity);
|
||||
|
||||
// If we already have enough rows to satisfy the filter, there is no need
|
||||
// to swap as we won't be writing more before the next convolution.
|
||||
|
@ -260,7 +260,7 @@ class DownscalingFilter final : public SurfaceFilter {
|
||||
|
||||
// Shift the buffer. We're just moving pointers here, so this is cheap.
|
||||
mRowsInWindow -= diff;
|
||||
mRowsInWindow = std::min(std::max(mRowsInWindow, 0), mWindowCapacity);
|
||||
mRowsInWindow = std::clamp(mRowsInWindow, 0, mWindowCapacity);
|
||||
|
||||
// If we already have enough rows to satisfy the filter, there is no need
|
||||
// to swap as we won't be writing more before the next convolution.
|
||||
|
@ -744,8 +744,8 @@ bool RasterImage::SetMetadata(const ImageMetadata& aMetadata,
|
||||
MOZ_ASSERT(mOrientation.IsIdentity(), "Would need to orient hotspot point");
|
||||
|
||||
auto hotspot = aMetadata.GetHotspot();
|
||||
mHotspot.x = std::max(std::min(hotspot.x.value, mSize.width - 1), 0);
|
||||
mHotspot.y = std::max(std::min(hotspot.y.value, mSize.height - 1), 0);
|
||||
mHotspot.x = std::clamp(hotspot.x.value, 0, mSize.width - 1);
|
||||
mHotspot.y = std::clamp(hotspot.y.value, 0, mSize.height - 1);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -262,7 +262,7 @@ nsresult imgFrame::InitForDecoderRecycle(const AnimationParams& aAnimParams) {
|
||||
// is still in use for some other purpose, it won't be returned to the pool
|
||||
// and its owner can hold onto it forever without additional impact here.
|
||||
int32_t refreshInterval =
|
||||
std::max(std::min(nsRefreshDriver::DefaultInterval(), 20), 4);
|
||||
std::clamp(nsRefreshDriver::DefaultInterval(), 4, 20);
|
||||
TimeDuration waitInterval =
|
||||
TimeDuration::FromMilliseconds(refreshInterval >> 2);
|
||||
TimeStamp timeout =
|
||||
|
Loading…
Reference in New Issue
Block a user