[cairo] Scrolling/Copying
Carl Worth
cworth at cworth.org
Thu Jun 23 12:47:18 PDT 2005
On 23 Jun 2005 21:29:26 +0200, "Tim Teulings" wrote:
> Ah sad story :-/ The (temporary) fix would be nice - or is there a
> workaround I can implement in my application? Would the fix be
> integrated in the next cairo version?
I think we can get the fix in place for an upcoming cairo
snapshot. The fix involves calling XCopyArea directly which is just
what you want anyway for performance reasons.
I've just added this to the roadmap for cairo 0.5.2. See cairo/ROADMAP
in CVS, which can also be found here:
http://cvs.cairographics.org/*checkout*/cairo/ROADMAP
> Nevertheless, can someone still explain me the to coords params to the
> cairo_set_source_surface method?
OK. Let me try this again.
The easiest use case is for drawing an entire image (within a
cairo_surface_t) at some position X,Y:
cairo_set_source_surface (cr, surface, X, Y);
cairo_paint (cr);
That will paint the surface so that its upper-left corner appears at
X, Y in user space.
As for what X,Y really mean, the implementation of
cairo_set_source_surface is the next easiest thing to look at, which
shows they are used as negative translation values for the pattern
matrix:
pattern = cairo_pattern_create_for_surface (surface);
cairo_matrix_init_translate (&matrix, -x, -y);
cairo_pattern_set_matrix (pattern, &matrix);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
As for what the pattern matrix means, it maps from pattern space,
(eg. the natural coordinate space of the image), to user space. Though
there is still a somewhat open question about what user space it maps
to, (consensus seems to be forming that the pattern should lock to the
user space in place at the time of cairo_set_source).
Is that any more clear?
Does anybody have suggestions for improving the documentation of
cairo_set_source_surface (copied below) ?
-Carl
/**
* cairo_set_source_surface:
* @cr: a cairo context
* @surface: a surface to be used to set the source pattern
* @x: User-space X coordinate for surface origin
* @y: User-space Y coordinate for surface origin
*
* This is a convenience function for creating a pattern from @surface
* and setting it as the source in @cr with cairo_set_source().
*
* The @x and @y parameters give the user-space coordinate at which
* the surface origin should appear. (The surface origin is its
* upper-left corner before any transformation has been applied.) The
* @x and @y patterns are negated and then set as translation values
* in the pattern matrix.
*
* Other than the initial translation pattern matrix, as described
* above, all other pattern attributes, (such as its extend mode), are
* set to the default values as in cairo_pattern_create_for_surface.
* The resulting pattern can be queried with cairo_get_source() so
* that these attributes can be modified if desired, (eg. to create a
* repeating pattern with cairo_pattern_set_extend()).
**/
-------------- 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/8bd8522e/attachment.pgp
More information about the cairo
mailing list