Bug 1375842 - increase SIMD padding for convolution filter to 31 bytes. r=jrmuizel

MozReview-Commit-ID: IAwY4xbA0P2
This commit is contained in:
Lee Salzman
2017-07-07 13:32:05 -04:00
parent e4eca7e523
commit 78e768b241
3 changed files with 12 additions and 8 deletions

View File

@@ -37,6 +37,10 @@ public:
bool ComputeResizeFilter(ResizeMethod aResizeMethod, int32_t aSrcSize, int32_t aDstSize);
static inline size_t PadBytesForSIMD(size_t aBytes) {
return (aBytes + 31) & ~31;
}
private:
UniquePtr<SkConvolutionFilter1D> mFilter;
};

View File

@@ -105,8 +105,8 @@ Downscaler::BeginFrame(const nsIntSize& aOriginalSize,
}
// Allocate the buffer, which contains scanlines of the original image.
// pad by 15 to handle overreads by the simd code
size_t bufferLen = mOriginalSize.width * sizeof(uint32_t) + 15;
// pad to handle overreads by the simd code
size_t bufferLen = gfx::ConvolutionFilter::PadBytesForSIMD(mOriginalSize.width * sizeof(uint32_t));
mRowBuffer.reset(new (fallible) uint8_t[bufferLen]);
if (MOZ_UNLIKELY(!mRowBuffer)) {
return NS_ERROR_OUT_OF_MEMORY;
@@ -125,8 +125,8 @@ Downscaler::BeginFrame(const nsIntSize& aOriginalSize,
}
bool anyAllocationFailed = false;
// pad by 15 to handle overreads by the simd code
const int rowSize = mTargetSize.width * sizeof(uint32_t) + 15;
// pad to handle overreads by the simd code
const size_t rowSize = gfx::ConvolutionFilter::PadBytesForSIMD(mTargetSize.width * sizeof(uint32_t));
for (int32_t i = 0; i < mWindowCapacity; ++i) {
mWindow[i] = new (fallible) uint8_t[rowSize];
anyAllocationFailed = anyAllocationFailed || mWindow[i] == nullptr;

View File

@@ -177,7 +177,7 @@ public:
// either valid or nullptr. That in turn ensures that ReleaseWindow() can
// clean up correctly.
bool anyAllocationFailed = false;
const uint32_t windowRowSizeInBytes = PaddedWidthInBytes(outputSize.width);
const size_t windowRowSizeInBytes = PaddedWidthInBytes(outputSize.width);
for (int32_t i = 0; i < mWindowCapacity; ++i) {
mWindow[i] = new (fallible) uint8_t[windowRowSizeInBytes];
anyAllocationFailed = anyAllocationFailed || mWindow[i] == nullptr;
@@ -261,11 +261,11 @@ protected:
private:
uint8_t* GetRowPointer() const { return mRowBuffer.get(); }
static uint32_t PaddedWidthInBytes(uint32_t aLogicalWidth)
static size_t PaddedWidthInBytes(size_t aLogicalWidth)
{
// Convert from width in BGRA/BGRX pixels to width in bytes, padding by 15
// Convert from width in BGRA/BGRX pixels to width in bytes, padding
// to handle overreads by the SIMD code inside Skia.
return aLogicalWidth * sizeof(uint32_t) + 15;
return gfx::ConvolutionFilter::PadBytesForSIMD(aLogicalWidth * sizeof(uint32_t));
}
void DownscaleInputRow()