[cairo] Scrolling/Copying
Carl Worth
cworth at cworth.org
Thu Jun 23 15:14:20 PDT 2005
On Thu, 23 Jun 2005 12:36:28 -0700, Bill Spitzak wrote:
> Carl Worth wrote:
> > I would write something like the following code to do that:
> >
> > cairo_set_source_surface (cr, x2 - x1, y2 - y1);
> > cairo_rectangle (cr, x2, y2, width, height);
> > cairo_fill (cr);
>
> I just realized that if this is going to work while the CTM is not the
> identity, it implies that somehow the CTM is cancelled out when the
> source and destination surface are the same, or that all surfaces
> contain a CTM. I don't think either of these are wanted for any uses
> other than this copy-area.
The above code "works" perfectly fine with a non-identity CTM, giving
a transformed version of the result that would be obtained with an
identity CTM.
But it is true that with a non-identity CTM, the code above does not
do a direct copy from the source surface, (instead the source surface
will be transformed according to the CTM). And it does seem like it
would be quite useful to be able to use CTM-transformed geometry while
copying pixels directly from a source surface.
So, I think I just talked myself into the fact that Owen had the right
idea all along that cairo_set_source should lock the pattern matrix to
refer to the user space at the time of cairo_set_source, (rather than
the user space in effect at the time of subsequent drawing
operations).
This will allow usage like the following to directly copy from a
source surface:
cairo_identity_matrix (cr);
cairo_set_source_surface (cr, surface, x, y);
cairo_scale (cr, sx, sy);
cairo_rectangle (cr, dx, dy, width, height);
giving the following result:
0,0-------------------------------------------------------------
| |
| source surface |
| x,y--------------------------------------------------- |
| | | |
| | rectangle | |
| | sx*dx,sy*dy--------- | |
| | |/////////| | |
| | |/////////| | |
| | |/////////| | |
| | ---------sx*(dx+width),sy*(dy+height) | |
| | | |
| --------------------------------------------------- |
| |
-------------------------------------------------------------
Where the source surface is untransformed and the operation can be
implemented by XCopyArea.
I'll sit down and fix the implementation to match this, which will let
us finally make the source-surface-scale-paint no longer fail.
-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050623/961e30f6/attachment.pgp
More information about the cairo
mailing list