While implementing a new CSS feature in Mozilla Gecko I stumbled across a bug regarding device offsets and scaling that make the feature quite glitchy. Device offsets seem to be unaffected by scaling when painted onto a surface with scaling applied. e.g. - surface A is scaled by 0.5, 0.5 - surface B has a device offset of -40, -40. - draw a rectangle on surface A at X=40, Y=40, width=20, height=20. This means the actual size is 20, 20, 10, 10 due to scaling. - draw a rectangle of exactly the same coordinates on surface B. - mask or paint surface B onto surface A. The result is that the rectangle on surface B is painted at half-size, but it is drawn at 40, 40, so the device offsets didn't allow the X or Y of B's rectangle to be scaled like A's. Hopefully this can be fixed soon as this blocks a proper implementation of text-shadow and box-shadow in Gecko.
Created attachment 17310 [details] Testcase When compiled, this dumps the contents of an image surface to stdout. The result should be that the orange rectangle (on the device offset surface) completely covers the blue rectangle (the reference that is drawn directly on the scaled surface).
You are right. This is a bug.
In the mean time you can avoid it by not using device offsets for this purpose. Use the pattern matrix instead.
If you want to jump into fixing this, _cairo_pattern_acquire_surface_for_surface() is the place.
Created attachment 17737 [details] [review] Apply the device offset before the destination transform The attached patch seems to fix the problem.
From reading the code, that patch looks right to me -- we presumably never ran into this because the device transform of things used as sources was always identity. I'd push this patch upstream, and add a testcase to the test suite for src-with-dev-transform.
Created attachment 17797 [details] [review] cairo test for device offset with scale
Created attachment 17798 [details] [review] New patch
Tests passed for me -- Jeff, can you commit and push this? I'll pull it into Mozilla from there.
Committed.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.