Loading

Paste #p0xbst66f

  1. Index: src/gfx.cpp
  2. ===================================================================
  3. --- src/gfx.cpp (revision 27323)
  4. +++ src/gfx.cpp (working copy)
  5. @@ -175,30 +175,24 @@
  6.  
  7.     assert(width > 0);
  8.  
  9. +   /* Clipping rectangle. Slightly extended so we can ignore the width of the line. */
  10. +   uint extra = CeilDiv(3 * width, 4); // not less then "width * sqrt(2) / 2"
  11. +   Rect clip = { -extra, -extra, screen_width - 1 + extra, screen_height - 1 + extra };
  12. +
  13.     if (y2 == y) {
  14.         /* Special case: horizontal line. */
  15. -       blitter->DrawLine(video,
  16. -               Clamp(x, 0, screen_width), y,
  17. -               Clamp(x2, 0, screen_width), y2,
  18. -               screen_width, screen_height, colour, width, dash);
  19. +       if (y >= clip.top && y <= clip.bottom) blitter->DrawLine(video, x, y, x2, y, screen_width, screen_height, colour, width, dash);
  20.         return;
  21.     }
  22.     if (x2 == x) {
  23.         /* Special case: vertical line. */
  24. -       blitter->DrawLine(video,
  25. -               x, Clamp(y, 0, screen_height),
  26. -               x2, Clamp(y2, 0, screen_height),
  27. -               screen_width, screen_height, colour, width, dash);
  28. +       if (x >= clip.left && x <= clip.right) blitter->DrawLine(video, x, y, x2, y, screen_width, screen_height, colour, width, dash);
  29.         return;
  30.     }
  31.  
  32.     int grade_y = y2 - y;
  33.     int grade_x = x2 - x;
  34.  
  35. -   /* Clipping rectangle. Slightly extended so we can ignore the width of the line. */
  36. -   uint extra = CeilDiv(3 * width, 4); // not less then "width * sqrt(2) / 2"
  37. -   Rect clip = { -extra, -extra, screen_width - 1 + extra, screen_height - 1 + extra };
  38. -
  39.     /* prevent integer overflows. */
  40.     int margin = 1;
  41.     while (INT_MAX / abs(grade_y) < max(abs(clip.left - x), abs(clip.right - x))) {
  42.  

Comments