dix: reduce the work done by ApplySoftening
We can modify fdx/fdy in-place rather than requiring dx/dy as well. And the decision to soften can be made in the caller (unless decided by the velocity state). Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
This commit is contained in:
parent
5870d507ce
commit
81c6e79f42
|
@ -708,21 +708,21 @@ ApplySimpleSoftening(int prev_delta, int delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Soften the delta based on previous deltas stored in vel.
|
||||||
|
*
|
||||||
|
* @param[in,out] fdx Delta X, modified in-place.
|
||||||
|
* @param[in,out] fdx Delta Y, modified in-place.
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
ApplySoftening(
|
ApplySoftening(
|
||||||
DeviceVelocityPtr vel,
|
DeviceVelocityPtr vel,
|
||||||
int dx,
|
|
||||||
int dy,
|
|
||||||
float* fdx,
|
float* fdx,
|
||||||
float* fdy,
|
float* fdy)
|
||||||
BOOL do_soften)
|
|
||||||
{
|
{
|
||||||
if (do_soften && vel->use_softening) {
|
if (vel->use_softening) {
|
||||||
*fdx = ApplySimpleSoftening(vel->last_dx, dx);
|
*fdx = ApplySimpleSoftening(vel->last_dx, *fdx);
|
||||||
*fdy = ApplySimpleSoftening(vel->last_dy, dy);
|
*fdy = ApplySimpleSoftening(vel->last_dy, *fdy);
|
||||||
} else {
|
|
||||||
*fdx = dx;
|
|
||||||
*fdy = dy;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1118,7 +1118,7 @@ acceleratePointerPredictable(
|
||||||
ValuatorMask* val,
|
ValuatorMask* val,
|
||||||
CARD32 evtime)
|
CARD32 evtime)
|
||||||
{
|
{
|
||||||
float fdx, fdy, tmp, mult; /* no need to init */
|
float tmp, mult; /* no need to init */
|
||||||
int dx = 0, dy = 0, tmpi;
|
int dx = 0, dy = 0, tmpi;
|
||||||
DeviceVelocityPtr velocitydata = GetDevicePredictableAccelData(dev);
|
DeviceVelocityPtr velocitydata = GetDevicePredictableAccelData(dev);
|
||||||
Bool soften = TRUE;
|
Bool soften = TRUE;
|
||||||
|
@ -1153,10 +1153,11 @@ acceleratePointerPredictable(
|
||||||
(float)dev->ptrfeed->ctrl.den);
|
(float)dev->ptrfeed->ctrl.den);
|
||||||
|
|
||||||
if(mult != 1.0f || velocitydata->const_acceleration != 1.0f) {
|
if(mult != 1.0f || velocitydata->const_acceleration != 1.0f) {
|
||||||
ApplySoftening(velocitydata,
|
float fdx = dx,
|
||||||
dx, dy,
|
fdy = dy;
|
||||||
&fdx, &fdy,
|
|
||||||
(mult > 1.0f) && soften);
|
if (mult > 1.0f && soften)
|
||||||
|
ApplySoftening(velocitydata, &fdx, &fdy);
|
||||||
ApplyConstantDeceleration(velocitydata, &fdx, &fdy);
|
ApplyConstantDeceleration(velocitydata, &fdx, &fdy);
|
||||||
|
|
||||||
/* Calculate the new delta (with accel) and drop it back
|
/* Calculate the new delta (with accel) and drop it back
|
||||||
|
|
Loading…
Reference in New Issue
Block a user