| Re: [cairo-compmgr] Re: magnifier plugin prove of concept |
[ Thread Index | Date Index | More lists.tuxfamily.org/cairo-compmgr Archives ]
hi, carlos
Very good job, you are in the right way.
Only some points : first instead create a window (which is redirected by
compositing), use cairo surface that you can create from root window
surface or cow surface in screen paint implementation like this:
if (!self->priv->surface)
{
CCMWindow* root = ccm_screen_get_root_window(screen);
cairo_surface_t* surface =
ccm_drawable_get_surface(CCM_DRAWABLE(root));
self->priv->surface = cairo_surface_create_similar(surface, w , h);
cairo_surface_destroy(surface);
}
After in window paint implementation create a context from this surface
and paint window on it, like you do, but don't forget the magnifier
offset in screen:
....
cairo_t* ctx = cairo_create(self->priv->surface);
// Translate to -x,-y offset of magnifier to have same coords of screen
cairo_translate(ctx, -x_offset, -y_offset);
// Magnifier scale
cairo_scale(ctx, scale_x, scale_y);
// Set clip zone to size of magnifier to don't draw outsite the
magnifier surface
cairo_rectangle(ctx, 0, 0, width, height);
cairo_clip(ctx);
// Paint the window
ret = ccm_window_plugin_paint (CCM_WINDOW_PLUGIN_PARENT(plugin), window,
ctx, surface);
....
You can also in this point, test if window is visible in magnifier with
ccm_region_rect_in to don't draw it when is outside magnifier.
To finish, i think we need a new function in screen which get cow
context like this :
cairo_t*
ccm_screen_get_context(CCMScreen* self)
{
if (!self->priv->ctx)
{
self->priv->ctx =
ccm_drawable_create_context(CCM_DRAWABLE(self->priv->cow));
}
return self->priv->ctx;
}
or add this context at parameters of ccm_screen_plugin_paint.
and after in end of screen paint, we can paint the magnifier like this:
cairo_t* context = ccm_screen_get_context(screen);
cairo_set_source_surface(context, self->priv->surface, x_pos, y_pos);
cairo_paint(context);
I write this code very quickly, and it can contains some mistakes ;)
Nicolas
--
gandalfn <gandalfn@xxxxxxxxxxxxxxxx>
Attachment:
signature.asc
Description: Ceci est une partie de message =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=
| Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |