[webkit-dev] Can someone explain tx/ty?

David Hyatt hyatt at apple.com
Mon Aug 23 10:11:34 PDT 2010


On Aug 23, 2010, at 4:33 AM, Maciej Stachowiak wrote:

> 
> 
> - tx, ty are the origin of the parent's coordinate system relative to the origin for its layer. When a layer paints, it establishes a CTM such that its own origin is 0, 0 (I think).
> 

They are relative to a painting root, which will basically either be the document or a compositing layer.

> The more obvious way, given the variable names, would be to make x(), y() an IntPoint, with a name like originInParentCoordinates()

It already is an IntPoint internally.  There's already a method to access it as a point.

IntPoint location() const

> (hopefully less verbose, but you get the idea). tx, ty could be named parentOffsetFromLayerCoordinates or something. This seems to be the intent of the names - that x,y is a point and tx, ty is a translation. But this doesn't work in point/size logic. You repeatedly add x(), y() to tx, ty to get a new tx, ty. But that means you're adding a point to a size and expecting to get a new size - but that's not how it works.
> 

I think a helper method that does the right thing solves this problem (rather than having to flip what x/y and tx/ty mean just to do some math operation).

dave

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20100823/8f7ea785/attachment.html>


More information about the webkit-dev mailing list