static float
round_to_granularity(float value, float granularity)
{
- return (float)(round(value / granularity) * granularity);
+ return roundf(value / granularity) * granularity;
+}
+
+static float
+line_width(float width, float granularity, const float range[2])
+{
+ assert(granularity >= 0);
+ assert(range[0] <= range[1]);
+
+ if (granularity > 0)
+ width = round_to_granularity(width, granularity);
+
+ return CLAMP(width, range[0], range[1]);
}
static void *
state->offset_clamp = rs_state->offset_clamp;
state->offset_scale = rs_state->offset_scale;
- state->line_width = round_to_granularity(rs_state->line_width,
- screen->props.limits.lineWidthGranularity);
+ state->line_width = line_width(rs_state->line_width,
+ screen->props.limits.lineWidthGranularity,
+ screen->props.limits.lineWidthRange);
return state;
}