void renderer_draw_yuv(struct xa_context *r, float src_x, float src_y, float src_w, float src_h, int dst_x, int dst_y, int dst_w, int dst_h, struct xa_surface *srf[]) { const int num_attribs = 2; /*pos + tex coord */ setup_vertex_data_yuv(r, src_x, src_y, src_w, src_h, dst_x, dst_y, dst_w, dst_h, srf); if (!r->scissor_valid) { r->scissor.minx = 0; r->scissor.miny = 0; r->scissor.maxx = r->dst->tex->width0; r->scissor.maxy = r->dst->tex->height0; } r->pipe->set_scissor_states(r->pipe, 0, 1, &r->scissor); cso_set_vertex_elements(r->cso, num_attribs, r->velems); util_draw_user_vertex_buffer(r->cso, r->buffer, PIPE_PRIM_QUADS, 4, /* verts */ num_attribs); /* attribs/vert */ r->buffer_size = 0; xa_scissor_reset(r); }
static inline void renderer_draw(struct xa_context *r) { int num_verts = r->buffer_size / (r->attrs_per_vertex * NUM_COMPONENTS); if (!r->buffer_size) return; if (!r->scissor_valid) { r->scissor.minx = 0; r->scissor.miny = 0; r->scissor.maxx = r->dst->tex->width0; r->scissor.maxy = r->dst->tex->height0; } r->pipe->set_scissor_states(r->pipe, 0, 1, &r->scissor); cso_set_vertex_elements(r->cso, r->attrs_per_vertex, r->velems); util_draw_user_vertex_buffer(r->cso, r->buffer, PIPE_PRIM_QUADS, num_verts, /* verts */ r->attrs_per_vertex); /* attribs/vert */ r->buffer_size = 0; xa_scissor_reset(r); }
/* Set up framebuffer, viewport and vertex shader constant buffer * state for a particular destinaton surface. In all our rendering, * these concepts are linked. */ void renderer_bind_destination(struct xa_context *r, struct pipe_surface *surface) { int width = surface->width; int height = surface->height; struct pipe_framebuffer_state fb; struct pipe_viewport_state viewport; xa_scissor_reset(r); /* Framebuffer uses actual surface width/height */ memset(&fb, 0, sizeof fb); fb.width = surface->width; fb.height = surface->height; fb.nr_cbufs = 1; fb.cbufs[0] = surface; fb.zsbuf = 0; /* Viewport just touches the bit we're interested in: */ viewport.scale[0] = width / 2.f; viewport.scale[1] = height / 2.f; viewport.scale[2] = 1.0; viewport.scale[3] = 1.0; viewport.translate[0] = width / 2.f; viewport.translate[1] = height / 2.f; viewport.translate[2] = 0.0; viewport.translate[3] = 0.0; /* Constant buffer set up to match viewport dimensions: */ if (r->fb_width != width || r->fb_height != height) { float vs_consts[8] = { 2.f / width, 2.f / height, 1, 1, -1, -1, 0, 0 }; r->fb_width = width; r->fb_height = height; renderer_set_constants(r, PIPE_SHADER_VERTEX, vs_consts, sizeof vs_consts); } cso_set_framebuffer(r->cso, &fb); cso_set_viewport(r->cso, &viewport); }