Bug 16469 - Device offset is not affected by scaling
Summary: Device offset is not affected by scaling
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 1.6.5
Hardware: Other All
: medium normal
Assignee: Jeff Muizelaar
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-22 18:55 UTC by Michael Ventnor
Modified: 2008-07-21 19:27 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Testcase (1.26 KB, text/plain)
2008-06-22 18:56 UTC, Michael Ventnor
Details
Apply the device offset before the destination transform (717 bytes, patch)
2008-07-17 19:35 UTC, Jeff Muizelaar
Details | Splinter Review
cairo test for device offset with scale (4.15 KB, patch)
2008-07-21 08:18 UTC, Jeff Muizelaar
Details | Splinter Review
New patch (1.10 KB, patch)
2008-07-21 08:19 UTC, Jeff Muizelaar
Details | Splinter Review

Description Michael Ventnor 2008-06-22 18:55:06 UTC
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.
Comment 1 Michael Ventnor 2008-06-22 18:56:33 UTC
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).
Comment 2 Behdad Esfahbod 2008-06-22 20:11:32 UTC
You are right.  This is a bug.
Comment 3 Behdad Esfahbod 2008-06-22 20:12:39 UTC
In the mean time you can avoid it by not using device offsets for this purpose.  Use the pattern matrix instead.
Comment 4 Behdad Esfahbod 2008-06-22 20:15:21 UTC
If you want to jump into fixing this, _cairo_pattern_acquire_surface_for_surface() is the place.
Comment 5 Jeff Muizelaar 2008-07-17 19:35:53 UTC
Created attachment 17737 [details] [review]
Apply the device offset before the destination transform

The attached patch seems to fix the problem.
Comment 6 Vladimir Vukicevic 2008-07-21 01:52:11 UTC
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.
Comment 7 Jeff Muizelaar 2008-07-21 08:18:52 UTC
Created attachment 17797 [details] [review]
cairo test for device offset with scale
Comment 8 Jeff Muizelaar 2008-07-21 08:19:44 UTC
Created attachment 17798 [details] [review]
New patch
Comment 9 Vladimir Vukicevic 2008-07-21 16:33:16 UTC
Tests passed for me -- Jeff, can you commit and push this?  I'll pull it into Mozilla from there.
Comment 10 Jeff Muizelaar 2008-07-21 19:27:20 UTC
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.