void xa_copy(struct xa_context *ctx, int dx, int dy, int sx, int sy, int width, int height) { struct pipe_box src_box; if (ctx->simple_copy) { u_box_2d(sx, sy, width, height, &src_box); ctx->pipe->resource_copy_region(ctx->pipe, ctx->dst->tex, 0, dx, dy, 0, ctx->src->tex, 0, &src_box); } else renderer_copy(ctx, dx, dy, sx, sy, width, height, (float) width, (float) height); }
XA_EXPORT void xa_copy(struct xa_context *ctx, int dx, int dy, int sx, int sy, int width, int height) { struct pipe_box src_box; xa_scissor_update(ctx, dx, dy, dx + width, dy + height); if (ctx->simple_copy) { u_box_2d(sx, sy, width, height, &src_box); ctx->pipe->resource_copy_region(ctx->pipe, ctx->dst->tex, 0, dx, dy, 0, ctx->src->tex, 0, &src_box); } else renderer_copy(ctx, dx, dy, sx, sy, width, height, (float) ctx->src->tex->width0, (float) ctx->src->tex->height0); }
static void vg_copy_texture(struct vg_context *ctx, struct pipe_resource *dst, VGint dx, VGint dy, struct pipe_sampler_view *src, VGint sx, VGint sy, VGint width, VGint height) { VGfloat dst_loc[4], src_loc[4]; dst_loc[0] = dx; dst_loc[1] = dy; dst_loc[2] = width; dst_loc[3] = height; src_loc[0] = sx; src_loc[1] = sy; src_loc[2] = width; src_loc[3] = height; vg_get_copy_coords(src_loc, src->texture->width0, src->texture->height0, dst_loc, dst->width0, dst->height0); if (src_loc[2] >= 0 && src_loc[3] >= 0 && dst_loc[2] >= 0 && dst_loc[3] >= 0) { struct pipe_surface *surf, surf_tmpl; /* get the destination surface */ u_surface_default_template(&surf_tmpl, dst, PIPE_BIND_RENDER_TARGET); surf = ctx->pipe->create_surface(ctx->pipe, dst, &surf_tmpl); if (surf && renderer_copy_begin(ctx->renderer, surf, VG_TRUE, src)) { renderer_copy(ctx->renderer, dst_loc[0], dst_loc[1], dst_loc[2], dst_loc[3], src_loc[0], src_loc[1], src_loc[2], src_loc[3]); renderer_copy_end(ctx->renderer); } pipe_surface_reference(&surf, NULL); } }
void renderer_copy_surface(struct renderer *ctx, struct pipe_surface *src, int srcX0, int srcY0, int srcX1, int srcY1, struct pipe_surface *dst, int dstX0, int dstY0, int dstX1, int dstY1, float z, unsigned filter) { struct pipe_context *pipe = ctx->pipe; struct pipe_screen *screen = pipe->screen; struct pipe_sampler_view view_templ; struct pipe_sampler_view *view; struct pipe_box src_box; struct pipe_resource texTemp, *tex; const struct pipe_framebuffer_state *fb = &ctx->g3d.fb; const int srcW = abs(srcX1 - srcX0); const int srcH = abs(srcY1 - srcY0); const int srcLeft = MIN2(srcX0, srcX1); const int srcTop = MIN2(srcY0, srcY1); assert(filter == PIPE_TEX_MIPFILTER_NEAREST || filter == PIPE_TEX_MIPFILTER_LINEAR); if (srcLeft != srcX0) { /* left-right flip */ int tmp = dstX0; dstX0 = dstX1; dstX1 = tmp; } if (srcTop != srcY0) { /* up-down flip */ int tmp = dstY0; dstY0 = dstY1; dstY1 = tmp; } assert(screen->is_format_supported(screen, src->format, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW)); assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW)); assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D, 0, PIPE_BIND_RENDER_TARGET)); /* * XXX for now we're always creating a temporary texture. * Strictly speaking that's not always needed. */ /* create temp texture */ memset(&texTemp, 0, sizeof(texTemp)); texTemp.target = PIPE_TEXTURE_2D; texTemp.format = src->format; texTemp.last_level = 0; texTemp.width0 = srcW; texTemp.height0 = srcH; texTemp.depth0 = 1; texTemp.array_size = 1; texTemp.bind = PIPE_BIND_SAMPLER_VIEW; tex = screen->resource_create(screen, &texTemp); if (!tex) return; u_sampler_view_default_template(&view_templ, tex, tex->format); view = pipe->create_sampler_view(pipe, tex, &view_templ); if (!view) return; u_box_2d_zslice(srcLeft, srcTop, src->u.tex.first_layer, srcW, srcH, &src_box); pipe->resource_copy_region(pipe, tex, 0, 0, 0, 0, /* dest */ src->texture, 0, &src_box); assert(floatsEqual(z, 0.0f)); /* draw */ if (fb->cbufs[0] == dst) { /* transform back to surface coordinates */ dstY0 = dst->height - dstY0; dstY1 = dst->height - dstY1; if (renderer_drawtex_begin(ctx, view)) { renderer_drawtex(ctx, dstX0, dstY0, dstX1 - dstX0, dstY1 - dstY0, 0, 0, view->texture->width0, view->texture->height0); renderer_drawtex_end(ctx); } } else { if (renderer_copy_begin(ctx, dst, VG_TRUE, view)) { renderer_copy(ctx, dstX0, dstY0, dstX1 - dstX0, dstY1 - dstY0, 0, 0, view->texture->width0, view->texture->height0); renderer_copy_end(ctx); } } }