[cairo] Re: about glitz yv12 support

ma liang bigmaliang at gmail.com
Wed Jun 21 01:42:23 PDT 2006


Hello, David:

2006/6/20, David Reveman <davidr at novell.com>:
> On Tue, 2006-06-20 at 11:17 +0800, ma liang wrote:

> > 3.If it is a YV12 surface, how can I set my "base[0]: y,  base[1]: u,
> > base[2]: v "data to the surface to display it?
>
> You want to upload data to the yv12 surface and display it by using
> glitz_composite with yv12 surface as source and some drawable as
> destination.
>
> To upload data into yv12 surface use glitz_set_pixels with a
> glitz_pixel_format_t structure set up correctly to match your data.
> scanline_order must be GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP for
> efficient loading. If your data is not in bottom-up scanline order, flip
> it when doing glitz_composite instead.
>
> -David
>
>
Thank you for your reply. But I am not very clear about how to use
glitz_composite
(sorry for I am a newbie with glitz).
Is there any example about this, or, if I have the following code,
what is the next step I need to do?
================================================================
dtempl.samples = 1;
dtempl.doublebuffer = 1;
mask = GLITZ_FORMAT_SAMPLES_MASK;
dformat = glitz_glx_find_window_format (display, screen, mask, &dtempl, 0);
drawable = glitz_glx_create_drawable_for_window (display, screen, dformat, win,
						 WIDTH_QY, HIGHT_QY);

templ.color.fourcc = GLITZ_FOURCC_YV12;
mask = GLITZ_FORMAT_FOURCC_MASK;
format = glitz_find_format (drawable, mask, &templ, 0);

surface = glitz_surface_create (drawable, format, WIDTH_QY, HIGHT_QY, 0, NULL);
size = (8*((width + 7) / 8) * height) + (2*( 8*((width + 15) /
16)*((height+1)/2) ));

pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
pf.xoffset = 0;
pf.skip_lines = 0;
pf.fourcc = GLITZ_FOURCC_YV12;
pf.masks.bpp = 12;
pf.masks.alpha_mask = 0x0;
pf.masks.red_mask =   0x0;
pf.masks.green_mask = 0x0;
pf.masks.blue_mask =  0x0;
pf.bytes_per_line = (((width * pf.masks.bpp) / 8) + 3) & -4;

/* data is a pointer to a frame base data, this frame size is WIDTH_QY
* HIGHT_QY */
buffer = glitz_pixel_buffer_create(drawable, (void *)data, size,
GLITZ_BUFFER_HINT_STREAM_DRAW);
glitz_set_pixels ((glitz_surface_t *) surface, 0, 0, width, height,
&pf, buffer);


More information about the cairo mailing list