Esempio n. 1
0
static void draw_glyph(struct glyph *g, float x, float y)
{
	int gx = (int)g->x;
	int gy = (int)g->y;
	int gwidth = (int)g->width;
	int gheight = (int)g->height;
	int ix = (int)(x - g->orig_x);
	int iy = (int)(y - gheight + g->orig_y);

	if(ix >= fb_width || iy >= fb_height)
		return;

	if(ix < 0) {
		gwidth += ix;
		gx -= ix;
		ix = 0;
	}
	if(iy < 0) {
		gheight += iy;
		gy -= iy;
		iy = 0;
	}
	if(ix + gwidth >= fb_width) {
		gwidth = fb_width - ix;
	}
	if(iy + gheight >= fb_height) {
		gheight = fb_height - iy;
	}

	if(gwidth <= 0 || gheight <= 0)
		return;

	unsigned char *dest = fb_pixels + (iy * fb_width + ix) * 4;
	unsigned char *src = gmap->pixels + gy * gmap->xsz + gx;

	if(use_alpha) {
		blit_blend(dest, src, gwidth, gheight);
	} else if(threshold > 0) {
		blit_thres(dest, src, gwidth, gheight);
	} else {
		blit_opaque(dest, src, gwidth, gheight);
	}
}
Esempio n. 2
0
static int process_blit(struct mdp_info *mdp, struct mdp_blit_req *req,
		 struct file *src_file, unsigned long src_start, unsigned long src_len,
		 struct file *dst_file, unsigned long dst_start, unsigned long dst_len)
{
	struct ppp_regs regs = {0};
	uint32_t luma_base;

#if PPP_DUMP_BLITS
	mdp_dump_blit(req);
#endif

	if (unlikely(req->src.format >= MDP_IMGTYPE_LIMIT ||
		     req->dst.format >= MDP_IMGTYPE_LIMIT)) {
		printk(KERN_ERR "mdp_ppp: img is of wrong format\n");
		return -EINVAL;
	}

	if (unlikely(req->src_rect.x > req->src.width ||
		     req->src_rect.y > req->src.height ||
		     req->dst_rect.x > req->dst.width ||
		     req->dst_rect.y > req->dst.height)) {
		printk(KERN_ERR "mdp_ppp: img rect is outside of img!\n");
		return -EINVAL;
	}

	if (unlikely(req->src_rect.x + req->src_rect.w > req->src.width ||
		     req->src_rect.y + req->src_rect.h > req->src.height ||
		     req->dst_rect.x + req->dst_rect.w > req->dst.width ||
		     req->dst_rect.y + req->dst_rect.h > req->dst.height)) {
		printk(KERN_ERR "mdp_ppp: img rect extends outside of img!\n");
		return -EINVAL;
	}

	/* set the src image configuration */
	regs.src_cfg = src_img_cfg[req->src.format];
	regs.src_cfg |= (req->src_rect.x & 0x1) ? PPP_SRC_BPP_ROI_ODD_X : 0;
	regs.src_cfg |= (req->src_rect.y & 0x1) ? PPP_SRC_BPP_ROI_ODD_Y : 0;
	regs.src_pack = pack_pattern[req->src.format];

	/* set the dest image configuration */
	regs.dst_cfg = dst_img_cfg[req->dst.format] | PPP_DST_OUT_SEL_AXI;
	regs.dst_pack = pack_pattern[req->dst.format];

	/* set src, bpp, start pixel and ystride */
	regs.src_bpp = mdp_get_bytes_per_pixel(req->src.format);
	luma_base = src_start + req->src.offset;
	regs.src0 = luma_base +
		get_luma_offset(&req->src, &req->src_rect, regs.src_bpp);
	regs.src1 = get_chroma_base(&req->src, luma_base, regs.src_bpp);
	regs.src1 += get_chroma_offset(&req->src, &req->src_rect, regs.src_bpp);
	regs.src_ystride = req->src.width * regs.src_bpp;
	set_src_region(&req->src, &req->src_rect, &regs);

	/* set dst, bpp, start pixel and ystride */
	regs.dst_bpp = mdp_get_bytes_per_pixel(req->dst.format);
	luma_base = dst_start + req->dst.offset;
	regs.dst0 = luma_base +
		get_luma_offset(&req->dst, &req->dst_rect, regs.dst_bpp);
	regs.dst1 = get_chroma_base(&req->dst, luma_base, regs.dst_bpp);
	regs.dst1 += get_chroma_offset(&req->dst, &req->dst_rect, regs.dst_bpp);
	regs.dst_ystride = req->dst.width * regs.dst_bpp;
	set_dst_region(&req->dst_rect, &regs);

	if (!valid_src_dst(src_start, src_len, dst_start, dst_len, req,
			   &regs)) {
		printk(KERN_ERR "mdp_ppp: final src or dst location is "
			"invalid, are you trying to make an image too large "
			"or to place it outside the screen?\n");
		return -EINVAL;
	}

	/* set up operation register */
	regs.op = 0;
	blit_rotate(req, &regs);
	blit_convert(req, &regs);
	if (req->flags & MDP_DITHER)
		regs.op |= PPP_OP_DITHER_EN;
	blit_blend(req, &regs);
	if (blit_scale(mdp, req, &regs)) {
		printk(KERN_ERR "mdp_ppp: error computing scale for img.\n");
		return -EINVAL;
	}
	blit_blur(mdp, req, &regs);
	regs.op |= dst_op_chroma[req->dst.format] |
		   src_op_chroma[req->src.format];

	/* if the image is YCRYCB, the x and w must be even */
	if (unlikely(req->src.format == MDP_YCRYCB_H2V1)) {
		req->src_rect.x = req->src_rect.x & (~0x1);
		req->src_rect.w = req->src_rect.w & (~0x1);
		req->dst_rect.x = req->dst_rect.x & (~0x1);
		req->dst_rect.w = req->dst_rect.w & (~0x1);
	}

	if (mdp_ppp_cfg_edge_cond(req, &regs))
		return -EINVAL;

	/* for simplicity, always write the chroma stride */
	regs.src_ystride &= 0x3fff;
	regs.src_ystride |= regs.src_ystride << 16;
	regs.dst_ystride &= 0x3fff;
	regs.dst_ystride |= regs.dst_ystride << 16;
	regs.bg_ystride &= 0x3fff;
	regs.bg_ystride |= regs.bg_ystride << 16;

#if PPP_DUMP_BLITS
	pr_info("%s: sending blit\n", __func__);
#endif
	send_blit(mdp, req, &regs, src_file, dst_file);
	return 0;
}