Closed Bug 432453 Opened 16 years ago Closed 16 years ago

dotted/dashed borders rendering with Qpainter surface very slow

Categories

(Core Graveyard :: Widget: Qt, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: romaxa, Assigned: romaxa)

References

()

Details

Attachments

(4 files, 2 obsolete files)

original page maemo.org
Attached file Oprofile data
Attached file Backtrace
I guess we have to recognize dotted/dashed drawing and draw it something like this:
QPen.setStyle(strokeStyle);
qp->drawLine...
> qp->drawLine...
No I'm wrong ....

We are asking to draw any borders (dotted/dashed/custom) with Qt::CustomDashLine,
but this is very slow...

I guess we have to use simple patterns Qt::DotLine/Qt::DashLine when it possible

Attached patch Possible way to fix this bug (obsolete) — Splinter Review
Vlad can you check this approach for fixing slow borders rendering?
Attachment #319776 - Flags: review?(vladimir)
Comment on attachment 319776 [details] [diff] [review]
Possible way to fix this bug

Hmm, good idea, but this approach won't work -- you'll end up using Qt::DashLine for every dash length, and Qt::DotLine for lengths 1 and 2.  What I would do instead here is something like:

style = Qt::NoPen;

if (style->num_dashes == 2) {
  if (style->dash[0] == style->line_width &&
      style->dash[1] == style->line_width * 2.0)
  {
    style = Qt::DotLine;
  } else if (style->dash[0] == style->line_width * 4.0 &&
             style->dash[1] == style->line_width * 2.0)
  {
    style = Qt::DashLine;
  }
}

if (style == Qt::NoPen) {
  // do real conversion
}

The 2 and 4 values are what Qt internally uses for DotLine/DashLine.

And then I'd patch layout/base/nsCSSRendering.cpp and add some #ifdef MOZ_WIDGET_QT's around where the dash pattern is set, and make the dash/dot patterns match up to the above.  That'll change behaviour some which means we'll change rendering on the web, and we'll have to figure out if that's ok, but that should have the same effect.

Are you sure that this is the actual performance issue, though?  I guess looking at the X11 paint engine code it handles DotLine/DashLine separately if it can (solid color, straight lines).
(In reply to comment #6)
> (From update of attachment 319776 [details] [diff] [review])
> Hmm, good idea, but this approach won't work -- you'll end up using
> Qt::DashLine for every dash length, and Qt::DotLine for lengths 1 and 2.  What

That was temporary hack, because in current implementation something wrong...
for me it fails to render properly next url:
data:text/html,<div style="height:1000px;border:5px dotted #c0c0c0;">

It just render dots in corner....

Attached patch Proposed fix rev2 (obsolete) — Splinter Review
Vlad what do you think about this fix?
Attachment #319776 - Attachment is obsolete: true
Attachment #334334 - Flags: review?(vladimir)
Attachment #319776 - Flags: review?(vladimir)
Also condition for dotted lines can be simplified:
if (!style->dash[0] || style->dash[0] == style->line_width)
Comment on attachment 334334 [details] [diff] [review]
Proposed fix rev2

This looks ok, but please add a comment before the #defines saying that this is an optimization based on the assumption that dots are 1*w and dashes are 3*w.

Also please fix the indentation in the added block -- that file uses 4-space indents, you've got 2-space indents happening.
Attachment #334334 - Flags: review?(vladimir) → review+
Comment on attachment 334334 [details] [diff] [review]
Proposed fix rev2


Wait, one problem:

>+       if (style->num_dashes == 2) {
>+           if ((style->dash[0] == style->line_width &&
>+                style->dash[1] == style->line_width && style->line_width <= 2.0) ||

This is ok. (<= 2.0? not < 2.0? I can't remember what the original condition is; <= is probably ok.)

>+               (style->dash[0] == 0.0 &&
>+                style->dash[1] == style->line_width * 2 && style->line_width > 2.0)

This however is only Dot if the line cap is ROUND -- it's not a dot if the line cap is anything else (where it'll be probably pretty solid).

>+               )
>+           {
>+               pstyle = Qt::DotLine;
>+           } else if (style->dash[0] == style->line_width * DASH_LENGTH &&
>+                      style->dash[1] == style->line_width * DASH_LENGTH)
>+           {

This is also only Dash if the line cap is BUTT (and possibly SQUARE, but Ithink just BUTT).
I think now it should be ok.
Attachment #334334 - Attachment is obsolete: true
Attachment #334390 - Flags: review?(vladimir)
Comment on attachment 334390 [details] [diff] [review]
Comment #11 fixes

Yep, lookgs good.. thanks!
Attachment #334390 - Flags: review?(vladimir) → review+
Assignee: nobody → romaxa
fixed in:
http://hg.mozilla.org/mozilla-central/index.cgi/rev/ab84d935f37e
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: