mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1015780 - Make Moz2D's GetAlignedStride() faster. r=Bas
--HG-- extra : rebase_source : 6e87f0f91cd9cab03facb789f1fee700175ba102
This commit is contained in:
parent
b731f7650c
commit
bac4b9d1ef
@ -138,14 +138,21 @@ struct AlignedArray
|
||||
T *mPtr;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns aStride increased, if necessary, so that it divides exactly into
|
||||
* |alignment|.
|
||||
*
|
||||
* Note that currently |alignment| must be a power-of-2. If for some reason we
|
||||
* want to support NPOT alignment we can revert back to this functions old
|
||||
* implementation.
|
||||
*/
|
||||
template<int alignment>
|
||||
int32_t GetAlignedStride(int32_t aStride)
|
||||
{
|
||||
if (aStride % alignment) {
|
||||
return aStride + (alignment - (aStride % alignment));
|
||||
}
|
||||
|
||||
return aStride;
|
||||
MOZ_ASSERT(aStride > 0 && (aStride & (aStride-1)) == 0,
|
||||
"This implementation currently require power-of-two");
|
||||
const int32_t mask = alignment - 1;
|
||||
return (aStride + mask) & ~mask;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user