boolean xorg_composite_bind_state(struct exa_context *exa, int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, PicturePtr pDstPicture, struct exa_pixmap_priv *pSrc, struct exa_pixmap_priv *pMask, struct exa_pixmap_priv *pDst) { struct pipe_surface *dst_surf = xorg_gpu_surface(exa->pipe, pDst); renderer_bind_destination(exa->renderer, dst_surf, pDst->width, pDst->height); bind_blend_state(exa, op, pSrcPicture, pMaskPicture, pDstPicture); bind_shaders(exa, op, pSrcPicture, pMaskPicture, pDstPicture, pSrc, pMask); bind_samplers(exa, op, pSrcPicture, pMaskPicture, pDstPicture, pSrc, pMask, pDst); setup_transforms(exa, pSrcPicture, pMaskPicture); if (exa->num_bound_samplers == 0 ) { /* solid fill */ renderer_begin_solid(exa->renderer); } else { renderer_begin_textures(exa->renderer, exa->num_bound_samplers); } pipe_surface_reference(&dst_surf, NULL); return TRUE; }
XA_EXPORT int xa_composite_prepare(struct xa_context *ctx, const struct xa_composite *comp) { struct xa_surface *dst_srf = comp->dst->srf; int ret; ret = xa_ctx_srf_create(ctx, dst_srf); if (ret != XA_ERR_NONE) return ret; ctx->dst = dst_srf; renderer_bind_destination(ctx, ctx->srf, ctx->srf->width, ctx->srf->height); ret = bind_composite_blend_state(ctx, comp); if (ret != XA_ERR_NONE) return ret; ret = bind_shaders(ctx, comp); if (ret != XA_ERR_NONE) return ret; bind_samplers(ctx, comp); if (ctx->num_bound_samplers == 0 ) { /* solid fill */ renderer_begin_solid(ctx); } else { renderer_begin_textures(ctx); ctx->comp = comp; } xa_ctx_srf_destroy(ctx); return XA_ERR_NONE; }
XA_EXPORT int xa_solid_prepare(struct xa_context *ctx, struct xa_surface *dst, uint32_t fg) { unsigned vs_traits, fs_traits; struct xa_shader shader; int width, height; int ret; ret = xa_ctx_srf_create(ctx, dst); if (ret != XA_ERR_NONE) return ret; if (ctx->srf->format == PIPE_FORMAT_L8_UNORM) xa_pixel_to_float4_a8(fg, ctx->solid_color); else xa_pixel_to_float4(fg, ctx->solid_color); ctx->has_solid_color = 1; ctx->dst = dst; width = ctx->srf->width; height = ctx->srf->height; #if 0 debug_printf("Color Pixel=(%d, %d, %d, %d), RGBA=(%f, %f, %f, %f)\n", (fg >> 24) & 0xff, (fg >> 16) & 0xff, (fg >> 8) & 0xff, (fg >> 0) & 0xff, exa->solid_color[0], exa->solid_color[1], exa->solid_color[2], exa->solid_color[3]); #endif vs_traits = VS_SOLID_FILL; fs_traits = FS_SOLID_FILL; renderer_bind_destination(ctx, ctx->srf, width, height); bind_solid_blend_state(ctx); cso_set_samplers(ctx->cso, PIPE_SHADER_FRAGMENT, 0, NULL); cso_set_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT, 0, NULL); shader = xa_shaders_get(ctx->shaders, vs_traits, fs_traits); cso_set_vertex_shader_handle(ctx->cso, shader.vs); cso_set_fragment_shader_handle(ctx->cso, shader.fs); renderer_begin_solid(ctx); xa_ctx_srf_destroy(ctx); return XA_ERR_NONE; }
boolean xorg_solid_bind_state(struct exa_context *exa, struct exa_pixmap_priv *pixmap, Pixel fg) { struct pipe_surface *dst_surf = xorg_gpu_surface(exa->pipe, pixmap); unsigned vs_traits, fs_traits; struct xorg_shader shader; pixel_to_float4(fg, exa->solid_color, pixmap->tex->format); exa->has_solid_color = TRUE; #if 0 debug_printf("Color Pixel=(%d, %d, %d, %d), RGBA=(%f, %f, %f, %f)\n", (fg >> 24) & 0xff, (fg >> 16) & 0xff, (fg >> 8) & 0xff, (fg >> 0) & 0xff, exa->solid_color[0], exa->solid_color[1], exa->solid_color[2], exa->solid_color[3]); #endif vs_traits = VS_SOLID_FILL; fs_traits = FS_SOLID_FILL; renderer_bind_destination(exa->renderer, dst_surf, pixmap->width, pixmap->height); bind_blend_state(exa, PictOpSrc, NULL, NULL, NULL); cso_set_samplers(exa->renderer->cso, PIPE_SHADER_FRAGMENT, 0, NULL); cso_set_sampler_views(exa->renderer->cso, PIPE_SHADER_FRAGMENT, 0, NULL); shader = xorg_shaders_get(exa->renderer->shaders, vs_traits, fs_traits); cso_set_vertex_shader_handle(exa->renderer->cso, shader.vs); cso_set_fragment_shader_handle(exa->renderer->cso, shader.fs); renderer_begin_solid(exa->renderer); pipe_surface_reference(&dst_surf, NULL); return TRUE; }