Re: [geometry] Replace isIdentity()?

On Sat, Jun 7, 2014 at 3:30 PM, Dirk Schulze <dschulze@adobe.com> wrote:

>
> On Jun 7, 2014, at 11:30 PM, Rik Cabanier <cabanier@gmail.com> wrote:
>
> > Agree with this completely. Please keep isIdentity() as currently
> > written in the spec.  The downside that some code might
> > seemingly-randomly take the quick or slow path depending on precise
> > operations seems better than the downside of maybeHasTransform(),
> > which'll just make it always take the slow path.
> >
> > 'maybeHasTransform' is the API that will give consistent behavior while
> 'isIdentity' might act randomly.
> > Looking at the webkit and mozilla codebases, 'maybeHasTransform' will
> almost always take you to the short path.
> > On top of that, it will also be faster to calculate.
>
> I took some time to check the WebKit code base:
>
> There are situations where we compute the transformation from the CTM of
> one element to the CTM of another element and then check for identity.
> There are situations where we transform the origin for later
> transformations and undo the origin translation later. (Even though no
> transformation was applied.)
> There are situations where we set a member variable to a computed and
> passed Transform and check it for identity.
>
> All of these patterns would always return ’not identity’ with
> maybeHasTransform(). I also checked if some of these patterns could be
> transformed to be able to use maybeHasTransform(). Some could but actually
> require the authors to have a deep understanding of the functionality of
> maybeHasTransform(). And the code base must be designed around
> maybeHasTransform() so that it is by far easier to write isIdentity()
> yourself. We would do the author a huge disservice in their application
> structure.
>
> It actually took me some time to check the creation path of just *one* of
> the transforms that are checked for identity. I wonder how you would be
> able to traverse all paths and get to such a general statement. I can
> assure you that it can *not* be generalized for the webkit code base. Since
> I did not went through all transformation creation paths yet, I can not
> even say if the patterns above are exclusively or even mostly used. I can
> just assume that the generalization doesn’t apply to Gecko either.
>

You're right that WebKit does a translate/translate back a bit in its SVG
text codebase. Sorry I missed that.
However, if you were to rewrite that code so it would be smarter (= don't
do the translation if it isn't needed like it does in other parts), you
would end up with a faster code path that would still work with
'maybeHasTransform'. In other words, it would be a better design.

Looking over both code bases, plain isIdentity is actually used quite
sparingly (with the exception of SVG in WK).

It does start to look like I'm being outnumbered here :-)

Received on Saturday, 7 June 2014 23:32:50 UTC