Bug 89888 - use scale() instead of getCTM/normalizeTransform/setCTM for svg text decorations
Summary: use scale() instead of getCTM/normalizeTransform/setCTM for svg text decorations
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mike Reed
URL:
Keywords:
: 89506 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-06-25 09:04 PDT by Mike Reed
Modified: 2012-06-28 12:49 PDT (History)
8 users (show)

See Also:


Attachments
Patch (2.61 KB, patch)
2012-06-25 09:09 PDT, Mike Reed
no flags Details | Formatted Diff | Diff
Patch (3.65 KB, patch)
2012-06-25 10:35 PDT, Mike Reed
no flags Details | Formatted Diff | Diff
Patch (3.90 KB, patch)
2012-06-26 05:41 PDT, Mike Reed
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Reed 2012-06-25 09:04:00 PDT
use scale() instead of getCTM/normalizeTransform/setCTM for svg text decorations
Comment 1 Mike Reed 2012-06-25 09:09:55 PDT
Created attachment 149302 [details]
Patch
Comment 2 Eric Seidel (no email) 2012-06-25 09:26:55 PDT
Why wouldn't all platforms want this path?  Why does Skia?
Comment 3 Mike Reed 2012-06-25 09:34:24 PDT
Why:

Skia-specific:
The current code does not play well if we try to record/playback the drawing commands, since the getCTM() is done once, and may not be the same matrix that is present during subsequent playback.

General:
The old code introduces a fair amount of complexity and heuristics (e.g. why do we normalize only around identity, and not other integral scale factors or integral translates?)

If other platforms want to opt-in to this change, I presume they will either remove the check, or add their platform to the list.
Comment 4 David Reveman 2012-06-25 09:35:37 PDT
Comment on attachment 149302 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=149302&action=review

> Source/WebCore/rendering/svg/SVGInlineTextBox.cpp:652
> +            context->save();

if we consider save/restore() lightweight, I'd prefer the save/restore pair outside the conditional so that only one "scalingFactor != 1" check is needed.
Comment 5 Mike Reed 2012-06-25 09:37:12 PDT
I can make that change. My original CL attempted to keep the existing flow as much as possible.

I do think save/restore are very efficient in skia, so it should not be a perf issue there.
Comment 6 Mike Reed 2012-06-25 09:38:04 PDT
always calling save/restore might be another reason to make this Skia specific, unless the other platforms feel the same way about their relative perf cost...
Comment 7 Eric Seidel (no email) 2012-06-25 09:48:37 PDT
I don't know what the current view on the cost of GraphicsContext::save/restore is.
Comment 8 Eric Seidel (no email) 2012-06-25 09:50:12 PDT
I'd prefer if we just removed the "old" code and used scale instead, if that's perceived as the better way.  We can re-visit adding the "old" code back for other platforms if scale is too slow.  The perf bots will answer these questions (but I doubt it matters).

So my suggestion would be to just change the code instead of adding yet another if-def.
Comment 9 Mike Reed 2012-06-25 10:24:47 PDT
I'll give it a try, and hope there are rebaselines on other platforms...
Comment 10 Mike Reed 2012-06-25 10:35:14 PDT
Created attachment 149319 [details]
Patch
Comment 11 Mike Reed 2012-06-25 10:36:44 PDT
patch #2 removes #ifdefs
Comment 12 Mike Reed 2012-06-25 11:35:48 PDT
PTAL
Comment 13 Eric Seidel (no email) 2012-06-25 13:08:46 PDT
Comment on attachment 149319 [details]
Patch

Am I reading correctly that this patch basically undoes this change: http://trac.webkit.org/changeset/78704/trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp?  Do you anticipate that this will cause rendering differences between 64 and 32 bit machines (for skia or otherwise)?
Comment 14 Mike Reed 2012-06-25 13:19:42 PDT
I would think it would, though zimmermann might comment on that. This is why I thought my change should be per-platform.
Comment 15 Eric Seidel (no email) 2012-06-25 13:25:34 PDT
I see.  I can understand your desire for this to be per-platform then.  I'd like to give Niko a day to comment.  He's working from Germany last I knew.
Comment 16 Dirk Schulze 2012-06-25 19:31:24 PDT
Comment on attachment 149319 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=149319&action=review

In general I like to do this, instead of the "normalizeTransform" logic. I reviewed the original patch and thought that it might be worth at that time. But changed my mind. Even if we see rounding differences. I still think it is a good idea if Niko looks over the patch as well.

r- because of the issues listed below. I am fine if someone else reviews a new patch, since I won't be available for the next weeks.

> Source/WebCore/ChangeLog:8
> +
> +        use scale() instead of getCTM/normalizeTransform/setCTM for svg text decorations.
> +        https://bugs.webkit.org/show_bug.cgi?id=89888
> +
> +        Reviewed by NOBODY (OOPS!).
> +
> +        No new tests. Current layouttests exercise this code path.

A detailed comment is missing what you are doing and why you are doing it.

> Source/WebCore/rendering/svg/SVGInlineTextBox.cpp:618
> +        context->save();

We have GraphicsContextStateSaver for save/restore. Can't this be used here? Also, why are you using save and restore here? I can remember that for some platforms it was quite an expensive operation. Can't you just unscale?

> Source/WebCore/rendering/svg/SVGInlineTextBox.cpp:623
> +        context->restore();

Some lines later there is a condition and another restore  is called. This seems dangerous, since no save was called before here.
Comment 17 Mike Reed 2012-06-26 05:37:41 PDT
(In reply to comment #16)
> (From update of attachment 149319 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=149319&action=review
> 
> In general I like to do this, instead of the "normalizeTransform" logic. I reviewed the original patch and thought that it might be worth at that time. But changed my mind. Even if we see rounding differences. I still think it is a good idea if Niko looks over the patch as well.
> 
> r- because of the issues listed below. I am fine if someone else reviews a new patch, since I won't be available for the next weeks.
> 
> > Source/WebCore/ChangeLog:8
> > +
> > +        use scale() instead of getCTM/normalizeTransform/setCTM for svg text decorations.
> > +        https://bugs.webkit.org/show_bug.cgi?id=89888
> > +
> > +        Reviewed by NOBODY (OOPS!).
> > +
> > +        No new tests. Current layouttests exercise this code path.
> 
> A detailed comment is missing what you are doing and why you are doing it.
> 
> > Source/WebCore/rendering/svg/SVGInlineTextBox.cpp:618
> > +        context->save();
> 
> We have GraphicsContextStateSaver for save/restore. Can't this be used here? Also, why are you using save and restore here? I can remember that for some platforms it was quite an expensive operation. Can't you just unscale?

Too numerically unstable. That is why we have save/restore.

> 
> > Source/WebCore/rendering/svg/SVGInlineTextBox.cpp:623
> > +        context->restore();
> 
> Some lines later there is a condition and another restore  is called. This seems dangerous, since no save was called before here.

This is from code that has always been here. The restore is balance a hidden save inside applyShadowToGraphicsContext().
Comment 18 Mike Reed 2012-06-26 05:41:57 PDT
Created attachment 149516 [details]
Patch
Comment 19 Mike Reed 2012-06-26 05:43:35 PDT
Updated comment, and replied to Dirk's comments.

PTAL
Comment 20 Nikolas Zimmermann 2012-06-26 07:50:20 PDT
Comment on attachment 149516 [details]
Patch

If there are no regressions, r=me. Reverting the mess is just right, it didn't fix anything after all, and was my rude attempt to get consistent results between 32bit/64bit mac machines, but as it effectively breaks things for Chromium, it should just go away.
Comment 21 WebKit Review Bot 2012-06-27 08:06:41 PDT
Comment on attachment 149516 [details]
Patch

Clearing flags on attachment: 149516

Committed r121343: <http://trac.webkit.org/changeset/121343>
Comment 22 WebKit Review Bot 2012-06-27 08:06:47 PDT
All reviewed patches have been landed.  Closing bug.
Comment 23 David Reveman 2012-06-28 12:49:36 PDT
*** Bug 89506 has been marked as a duplicate of this bug. ***