Re: [cairo-compmgr] Re: magnifier plugin prove of concept

[ Thread Index | Date Index | More lists.tuxfamily.org/cairo-compmgr Archives ]


Hi Nicolas,

Thanks for the hints. I also would like to inform that I just finish
to write a magnifier plugin that works well with all others plugins
(great, I'm starting to understand the code well :-). I only needed to
do some modifications due the need of some magnifier informations in
others parts of the code (I guess that your hints will help me avoid
these ugly modifications :-). I will read your hints with more
attention soon and apply then in the code, when I finish this I send
the result.

Best regards,
Carlos.

2008/1/20, gandalfn <gandalfn@xxxxxxxxxxxxxxxx>:
> 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>
>
>

---


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/