sna: Micro-optimise line extents for zero line width
Handling zero line widths is the common case, so avoid the extra work. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
3c01074507
commit
ff2eb116ef
|
|
@ -5192,19 +5192,11 @@ sna_poly_line_extents(DrawablePtr drawable, GCPtr gc,
|
|||
BoxPtr out)
|
||||
{
|
||||
BoxRec box;
|
||||
int extra = gc->lineWidth >> 1;
|
||||
bool clip, blt = true;
|
||||
|
||||
if (n == 0)
|
||||
return 0;
|
||||
|
||||
if (n > 1) {
|
||||
if (gc->joinStyle == JoinMiter)
|
||||
extra = 6 * gc->lineWidth;
|
||||
else if (gc->capStyle == CapProjecting)
|
||||
extra = gc->lineWidth;
|
||||
}
|
||||
|
||||
box.x2 = box.x1 = pt->x;
|
||||
box.y2 = box.y1 = pt->y;
|
||||
if (mode == CoordModePrevious) {
|
||||
|
|
@ -5234,11 +5226,20 @@ sna_poly_line_extents(DrawablePtr drawable, GCPtr gc,
|
|||
box.x2++;
|
||||
box.y2++;
|
||||
|
||||
if (extra) {
|
||||
box.x1 -= extra;
|
||||
box.x2 += extra;
|
||||
box.y1 -= extra;
|
||||
box.y2 += extra;
|
||||
if (gc->lineWidth) {
|
||||
int extra = gc->lineWidth >> 1;
|
||||
if (n > 1) {
|
||||
if (gc->joinStyle == JoinMiter)
|
||||
extra = 6 * gc->lineWidth;
|
||||
else if (gc->capStyle == CapProjecting)
|
||||
extra = gc->lineWidth;
|
||||
}
|
||||
if (extra) {
|
||||
box.x1 -= extra;
|
||||
box.x2 += extra;
|
||||
box.y1 -= extra;
|
||||
box.y2 += extra;
|
||||
}
|
||||
}
|
||||
|
||||
clip = trim_and_translate_box(&box, drawable, gc);
|
||||
|
|
|
|||
Loading…
Reference in New Issue