finding the size of a cairo surface

View: New views
2 Messages — Rating Filter:   Alert me  

finding the size of a cairo surface

by L A-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am trying to modify a piece of code that was written for
cairo_image_surfaces. I would like to use cairo directfb surfaces
instead of image surfaces (for hw accel) and I am trying to avoid
changing the API. The issue is the size of the surface. How can I
replace cairo_image_surface_get_width/height calls?

Thanks
Levent
_______________________________________________
cairo mailing list
cairo@...
http://lists.cairographics.org/mailman/listinfo/cairo

Re: finding the size of a cairo surface

by Chris Wilson-11 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Excerpts from L A's message of Mon Nov 09 09:04:29 +0000 2009:
> I am trying to modify a piece of code that was written for
> cairo_image_surfaces. I would like to use cairo directfb surfaces
> instead of image surfaces (for hw accel)

I have to warn you that the only operation directfb can accelerate is the
2D blit to "upload-to-screen". Everything else is better done with the CPU
(image surface) intermediates. (Though glyphs could be accelerated under
rare circumstances, you'd probably lose due to migration.)

> and I am trying to avoid
> changing the API. The issue is the size of the surface. How can I
> replace cairo_image_surface_get_width/height calls?

The first question is how did you create the surface without knowing the
size... But if you truly do not want to change your own API, then:

        void get_surface_size (cairo_surface_t *surface,
                               int *width, int *height)
        {
                cairo_t *cr;
                double x1, x2, y1, y2;

                cr = cairo_create (surface);
                cairo_clip_extents (surface, &x1, &y1, &x2, &y2);
                cairo_destroy (cr);

                *width = x2 - x1;
                *height = y2 - y1;
        }

I am intrigued as to what you are using directfb for - just checking
that existing users will be able to easily migrate to a KMS/DRM world.
-ickle
--
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
cairo mailing list
cairo@...
http://lists.cairographics.org/mailman/listinfo/cairo