示例#1
0
void
xglDestroyGC (GCPtr pGC)
{
    XGL_GC_PRIV (pGC);

    if (pGCPriv->fg)
	glitz_surface_destroy (pGCPriv->fg);

    if (pGCPriv->bg)
	glitz_surface_destroy (pGCPriv->bg);

    XGL_GC_UNWRAP (funcs);
    XGL_GC_UNWRAP (ops);
    (*pGC->funcs->DestroyGC) (pGC);
    XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
    XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);
}
cairo_surface_t *
_cairo_boilerplate_glitz_wgl_create_surface (const char			 *name,
					     cairo_content_t		  content,
					     int			  width,
					     int			  height,
					     int			  max_width,
					     int			  max_height,
					     cairo_boilerplate_mode_t	  mode,
					     int                          id,
					     void			**closure)
{
    glitz_surface_t *glitz_surface;
    cairo_surface_t *surface = NULL;
    glitz_wgl_target_closure_t *wglc;

    glitz_wgl_init (NULL);

    *closure = wglc = xmalloc (sizeof (glitz_wgl_target_closure_t));

    switch (content) {
    case CAIRO_CONTENT_COLOR:
	glitz_surface = _cairo_boilerplate_glitz_wgl_create_surface_internal (GLITZ_STANDARD_RGB24, width, height, NULL);
	break;
    case CAIRO_CONTENT_COLOR_ALPHA:
	glitz_surface = _cairo_boilerplate_glitz_wgl_create_surface_internal (GLITZ_STANDARD_ARGB32, width, height, NULL);
	break;
    default:
	CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-wgl test: %d\n", content);
	goto FAIL;
    }

    if (!glitz_surface)
	goto FAIL;

    surface = cairo_glitz_surface_create (glitz_surface);
    glitz_surface_destroy (glitz_surface);

    if (cairo_surface_status (surface))
	goto FAIL;

    wglc->base.width = width;
    wglc->base.height = height;
    wglc->base.content = content;
    status = cairo_boilerplate_surface_set_user_data (surface,
	                                      &glitz_closure_key, wglc, NULL);
    if (status == CAIRO_STATUS_SUCCESS)
	return surface;

    cairo_surface_destroy (surface);
    surface = cairo_boilerplate_surface_create_in_error (status);

 FAIL:
    glitz_wgl_fini ();
    free (wglc);
    return surface;
}
示例#3
0
void
glitz_texture_object_destroy (glitz_texture_object_t *texture)
{
    texture->ref_count--;
    if (texture->ref_count)
        return;

    glitz_surface_destroy (texture->surface);
    free (texture);
}
示例#4
0
void
xglValidateGC (GCPtr	     pGC,
	       unsigned long changes,
	       DrawablePtr   pDrawable)
{
    XGL_GC_PRIV (pGC);

    if (changes & GCTile)
    {
	if (!pGC->tileIsPixel &&
	    FbEvenTile (pGC->tile.pixmap->drawable.width *
			pDrawable->bitsPerPixel))
	    xglSyncBits (&pGC->tile.pixmap->drawable, NULL);
    }

    if (changes & GCStipple)
    {
	if (pGC->stipple)
	    xglSyncBits (&pGC->stipple->drawable, NULL);
    }

    XGL_GC_UNWRAP (funcs);
    XGL_GC_UNWRAP (ops);
    (*pGC->funcs->ValidateGC) (pGC, changes, pDrawable);
    XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
    XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);

    if (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
    {
	XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);

	if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface)
	{
	    glitz_format_t *format;

	    format = pPixmapPriv->pVisual->format.surface;
	    if (format->id != pGCPriv->id)
	    {
		XGL_SCREEN_PRIV (pDrawable->pScreen);

		pGCPriv->flags |= xglGCSoftwareDrawableFlag;

		if (pGCPriv->fg)
		    glitz_surface_destroy (pGCPriv->fg);

		pGCPriv->fg = glitz_surface_create (pScreenPriv->drawable,
						    format, 1, 1, 0, NULL);
		if (pGCPriv->fg)
		    glitz_surface_set_fill (pGCPriv->fg, GLITZ_FILL_REPEAT);

		if (pGCPriv->bg)
		    glitz_surface_destroy (pGCPriv->bg);

		pGCPriv->bg = glitz_surface_create (pScreenPriv->drawable,
						    format, 1, 1, 0, NULL);
		if (pGCPriv->bg)
		    glitz_surface_set_fill (pGCPriv->bg, GLITZ_FILL_REPEAT);

		pGCPriv->id = format->id;

		if (pGCPriv->fg && pGCPriv->bg)
		{
		    changes |= (GCForeground | GCBackground);
		    pGCPriv->flags &= ~xglGCSoftwareDrawableFlag;
		}
	    }
	}
	else
	    pGCPriv->flags |= xglGCSoftwareDrawableFlag;
    }

    if (changes & GCFunction)
    {
	switch (pGC->alu) {
	case GXclear:
	    pGCPriv->op = GLITZ_OPERATOR_CLEAR;
	    pGCPriv->flags &= ~xglGCBadFunctionFlag;
	    break;
	case GXcopy:
	    pGCPriv->op = GLITZ_OPERATOR_SRC;
	    pGCPriv->flags &= ~xglGCBadFunctionFlag;
	    break;
	case GXnoop:
	    pGCPriv->op = GLITZ_OPERATOR_DST;
	    pGCPriv->flags &= ~xglGCBadFunctionFlag;
	    break;
	default:
	    pGCPriv->flags |= xglGCBadFunctionFlag;
	    break;
	}
    }

    if (changes & GCPlaneMask)
    {
	FbBits mask;

	mask = FbFullMask (pDrawable->depth);

	if ((pGC->planemask & mask) != mask)
	    pGCPriv->flags |= xglGCPlaneMaskFlag;
	else
	    pGCPriv->flags &= ~xglGCPlaneMaskFlag;
    }

    if (!(pGCPriv->flags & xglGCSoftwareDrawableFlag))
    {
	if (changes & (GCForeground | GCBackground))
	{
	    glitz_pixel_format_t format;
	    glitz_buffer_t	 *buffer;
	    CARD32		 pixel;

	    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);

	    format.fourcc	  = GLITZ_FOURCC_RGB;
	    format.masks	  = pPixmapPriv->pVisual->pPixel->masks;
	    format.xoffset	  = 0;
	    format.skip_lines     = 0;
	    format.bytes_per_line = sizeof (CARD32);
	    format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;

	    buffer = glitz_buffer_create_for_data (&pixel);

	    if (changes & GCForeground)
	    {
		pixel = pGC->fgPixel;
		glitz_set_pixels (pGCPriv->fg, 0, 0, 1, 1, &format, buffer);
	    }

	    if (changes & GCBackground)
	    {
		pixel = pGC->bgPixel;
		glitz_set_pixels (pGCPriv->bg, 0, 0, 1, 1, &format, buffer);
	    }

	    glitz_buffer_destroy (buffer);
	}
    }
}
cairo_surface_t *
_cairo_boilerplate_glitz_glx_create_surface (const char			 *name,
					     cairo_content_t 		  content,
					     int			  width,
					     int			  height,
					     int			  max_width,
					     int			  max_height,
					     cairo_boilerplate_mode_t	  mode,
					     int                          id,
					     void			**closure)
{
    glitz_glx_target_closure_t *gxtc;
    glitz_surface_t  * glitz_surface;
    cairo_surface_t  * surface = NULL;
    cairo_status_t status;

    *closure = gxtc = xmalloc (sizeof (glitz_glx_target_closure_t));

    if (width == 0)
	width = 1;
    if (height == 0)
	height = 1;

    gxtc->dpy = XOpenDisplay (getenv("CAIRO_TEST_GLITZ_DISPLAY"));
    if (!gxtc->dpy) {
	CAIRO_BOILERPLATE_LOG ("Failed to open display: %s\n", XDisplayName(0));
	goto FAIL;
    }

    XSynchronize (gxtc->dpy, 1);

    gxtc->scr = DefaultScreen(gxtc->dpy);

    switch (content) {
    case CAIRO_CONTENT_COLOR:
	glitz_surface = _cairo_boilerplate_glitz_glx_create_surface_internal (GLITZ_STANDARD_RGB24, width, height, gxtc);
	break;
    case CAIRO_CONTENT_COLOR_ALPHA:
	glitz_surface = _cairo_boilerplate_glitz_glx_create_surface_internal (GLITZ_STANDARD_ARGB32, width, height, gxtc);
	break;
    case CAIRO_CONTENT_ALPHA:
    default:
	CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-glx test: %d\n", content);
	goto FAIL_CLOSE_DISPLAY;
    }
    if (!glitz_surface) {
	CAIRO_BOILERPLATE_LOG ("Failed to create glitz-glx surface\n");
	goto FAIL_CLOSE_DISPLAY;
    }

    surface = cairo_glitz_surface_create (glitz_surface);
    glitz_surface_destroy (glitz_surface);

    if (cairo_surface_status (surface))
	goto FAIL_CLOSE_DISPLAY;

    gxtc->base.width = width;
    gxtc->base.height = height;
    gxtc->base.content = content;
    status = cairo_boilerplate_surface_set_user_data (surface,
	                                      &glitz_closure_key, gxtc, NULL);
    if (status == CAIRO_STATUS_SUCCESS)
	return surface;

    cairo_surface_destroy (surface);
    surface = cairo_boilerplate_surface_create_in_error (status);

 FAIL_CLOSE_DISPLAY:
    glitz_glx_fini ();
    XCloseDisplay (gxtc->dpy);
 FAIL:
    free (gxtc);
    return surface;
}