コード例 #1
0
ファイル: viewer.c プロジェクト: jafp/eyebot
static void draw_center_point(int x, int y, int rr, int gg, int bb)
{
    int r, c, o, o1;

    // Skip drawing the point if is so close to the border
    // that we cannot draw a 10x10 dot
    if (x > (WIDTH - 5) || x < 5 || y > (HEIGHT - 5) || y < 5)
    {   
        return;
    }

    // Draw the blue center point
    for (r = y - 5; r < y + 5; r++)
    {
        //o = r * WIDTH * 4;
        for (c = x - 5; c < x + 5; c++)
        {   
            // Calculate pixel offet
            o = r * WIDTH + c;
            assert(o < SIZE);

            o1 = get_pixel_offset(o);
            assert(o1 < N_IMG_BYTES);

            set_pixel_value_at_off(o1, rr, gg, bb);
        }
    }
}
コード例 #2
0
ファイル: image.hpp プロジェクト: xaphier/Eternal-Lands
			/**
			 * Returns the pointer to the data of the given pixel
			 * location. Only valid for uncompressed formats.
			 * @param x The x position.
			 * @param y The y position.
			 * @param z The z position.
			 * @param face The face to use.
			 * @param mipmap The mipmap level to use.
			 * @return The pointer to the data.
			 */
			inline const void* get_pixel_data(const Uint32 x,
				const Uint32 y, const Uint32 z,
				const Uint16 face, const Uint16 mipmap) const
			{
				return static_cast<const Uint8* const>(
					get_buffer()->get_ptr()) +
					get_pixel_offset(x, y, z, face, mipmap);
			}
コード例 #3
0
ファイル: viewer.c プロジェクト: jafp/eyebot
static void draw_center_lines()
{
    int r, o, m;

    // Draw the red center line vertical
    m = WIDTH / 2;
    for (r = 0; r < 240; r++)
    {
        o = ((r * WIDTH) + m);
        set_pixel_value_at_off(get_pixel_offset(o), 255, 0, 0);
    }

    // Draw the red center line horizontal
    m = HEIGHT / 2;
    for (r = 0; r < 320; r++)
    {
        o = m * WIDTH + r;
        set_pixel_value_at_off(get_pixel_offset(o), 255, 0, 0);
    }
}
コード例 #4
0
ファイル: image.hpp プロジェクト: xaphier/Eternal-Lands
			/**
			 * Returns the pointer to the data of the given
			 * location.
			 * @param x The x position.
			 * @param y The y position.
			 * @param z The z position.
			 * @param face The face to use.
			 * @param mipmap The mipmap level to use.
			 * @return The pointer to the data.
			 */
			inline const void* const get_data(const Uint32 x,
				const Uint32 y, const Uint32 z,
				const Uint16 face, const Uint16 mipmap) const
			{
				if (get_compressed())
				{
					return static_cast<const Uint8*>(
						get_buffer()->get_ptr()) +
						get_block_offset(x, y,z, face,
							mipmap);
				}

				return static_cast<const Uint8*>(get_buffer(
					)->get_ptr()) + get_pixel_offset(x, y,
						z, face, mipmap);
			}
コード例 #5
0
ファイル: Video.cpp プロジェクト: Sonophoto/Soar-SC
  void Video::set_2d_view(const std::pair<Point2f, Point2f> &camera2d, const std::pair<Point2i, Point2i> &viewport, const bool &fix_aspect_ratio) {
    m_3d = false;

    set_viewport(calculate_viewport(camera2d, viewport, fix_aspect_ratio));

    const Matrix4f view = Matrix4f::Identity();
    set_view_matrix(view);

    const std::pair<Point2i, Point2i> &vp = get_viewport();
    Point2f offset = get_pixel_offset();
    offset.x *= (camera2d.second.x - camera2d.first.x) / (vp.second.x - vp.first.x);
    offset.y *= (camera2d.second.y - camera2d.first.y) / (vp.second.y - vp.first.y);

    const Matrix4f projection = Matrix4f::Orthographic(camera2d.first.x + offset.x,
                                                       camera2d.second.x + offset.x,
                                                       camera2d.second.y + offset.y,
                                                       camera2d.first.y + offset.y,
                                                       ZENI_2D_NEAR, ZENI_2D_FAR);
    set_projection_matrix(projection);
  }
コード例 #6
0
enum bverror do_blit(struct bvbltparams *bvbltparams,
		     struct gcbatch *batch,
		     struct surfaceinfo *srcinfo)
{
	enum bverror bverror = BVERR_NONE;
	struct gccontext *gccontext = get_context();

	struct gcmosrc0 *gcmosrc0;
	struct gcmosrc *gcmosrc;
	struct gcblit *gcblit;

	unsigned int index;
	struct bvbuffmap *dstmap = NULL;
	struct bvbuffmap *srcmap = NULL;

	struct surfaceinfo *dstinfo;
	int dstshiftX, dstshiftY;
	int dstpixalign, dstbyteshift;
	int dstoffsetX, dstoffsetY;

	int srcshiftX, srcshiftY, srctopedge;
	struct gcrect srcclipped;
	int srcsurfwidth, srcsurfheight;
	unsigned int physwidth, physheight;
	int orthogonal;
	int multisrc;

	GCENTER(GCZONE_BLIT);

	/* 3-plane source not supported. */
	if ((srcinfo->format.type == BVFMT_YUV) &&
	    (srcinfo->format.cs.yuv.planecount == 3)) {
		BVSETBLTERROR((srcinfo->index == 0)
					? BVERR_SRC1GEOM_FORMAT
					: BVERR_SRC2GEOM_FORMAT,
			      "unsupported source%d format.",
			      srcinfo->index + 1);
		goto exit;
	}

	/* Get a shortcut to the destination surface. */
	dstinfo = &batch->dstinfo;

	/* Parse destination parameters. */
	bverror = parse_destination(bvbltparams, batch);
	if (bverror != BVERR_NONE)
		goto exit;

	/* Setup rotation. */
	process_dest_rotation(bvbltparams, batch);


	/***********************************************************************
	 * Determine source surface alignment offset.
	 */

	/* Determine whether the source and the destination are orthogonal
	 * to each other. */
	orthogonal = (srcinfo->angle % 2) != (dstinfo->angle % 2);

	/* Compute clipped source rectangle. */
	srcclipped.left   = srcinfo->rect.left   + batch->clipdelta.left;
	srcclipped.top    = srcinfo->rect.top    + batch->clipdelta.top;
	srcclipped.right  = srcinfo->rect.right  + batch->clipdelta.right;
	srcclipped.bottom = srcinfo->rect.bottom + batch->clipdelta.bottom;
	GCPRINT_RECT(GCZONE_SURF, "clipped source", &srcclipped);

	/* Validate the source rectangle. */
	if (!valid_rect(srcinfo->geom, &srcclipped)) {
		BVSETBLTERROR((srcinfo->index == 0)
					? BVERR_SRC1RECT
					: BVERR_SRC2RECT,
			      "invalid source rectangle.");
		goto exit;
	}

	/* Compute the source surface shift. */
	switch (srcinfo->angle) {
	case ROT_ANGLE_0:
		srctopedge = srcclipped.top;
		srcshiftX = srcclipped.left - batch->dstadjusted.left;
		srcshiftY = srctopedge - batch->dstadjusted.top;
		break;

	case ROT_ANGLE_90:
		srctopedge = srcinfo->geom->width - srcclipped.left;
		srcshiftX = srcclipped.top - batch->dstadjusted.top;
		srcshiftY = srctopedge
			  - (batch->dstwidth - batch->dstadjusted.left);
		srctopedge += 1;
		break;

	case ROT_ANGLE_180:
		srctopedge = srcinfo->geom->height - srcclipped.top;
		srcshiftX = (srcinfo->geom->width - srcclipped.left)
			  - (batch->dstwidth - batch->dstadjusted.left);
		srcshiftY = srctopedge
			  - (batch->dstheight - batch->dstadjusted.top);
		srctopedge += 1;
		break;

	case ROT_ANGLE_270:
		srctopedge = srcclipped.left;
		srcshiftX = (srcinfo->geom->height - srcclipped.top)
			  - (batch->dstheight - batch->dstadjusted.top);
		srcshiftY = srctopedge - batch->dstadjusted.left;
		break;

	default:
		srctopedge = 0;
		srcshiftX = 0;
		srcshiftY = 0;
	}

	/* We cannot be in the middle of a sample, currently only YUV formats
	 * can have subsamples. Adjust vertical position as necessary.
	 * Horizontal position will be adjusted based on the byte offset and
	 * base address alignment requirement. This assumes that if we are
	 * aligned on the base address, then we are also aligned at the
	 * beginning of a sample. */
	if (srcinfo->format.type == BVFMT_YUV) {
		int mody = (srctopedge + srcshiftY)
			 % srcinfo->format.cs.yuv.ysample;

		if (mody < 0)
			mody = srcinfo->format.cs.yuv.ysample + mody;

		srcshiftY -= mody;
		srcinfo->ypixalign = -mody;
	} else {
		srcinfo->ypixalign = 0;
	}

	/* Compute the source surface offset in bytes. */
	srcinfo->bytealign = srcshiftY * (int) srcinfo->geom->virtstride
			   + srcshiftX * (int) srcinfo->format.bitspp / 8;

	/* Compute the source offset in pixels needed to compensate
	 * for the surface base address misalignment if any. */
	srcinfo->xpixalign = get_pixel_offset(srcinfo, srcinfo->bytealign);

	GCDBG(GCZONE_SURF, "source surface %d:\n", srcinfo->index + 1);
	GCDBG(GCZONE_SURF, "  surface offset (pixels) = %d,%d\n",
	      srcshiftX, srcshiftY);
	GCDBG(GCZONE_SURF, "  surface offset (bytes) = 0x%08X\n",
	      srcinfo->bytealign);
	GCDBG(GCZONE_SURF, "  srcpixalign = %d,%d\n",
	      srcinfo->xpixalign, srcinfo->ypixalign);

	/* Apply the source alignment. */
	srcinfo->bytealign += srcinfo->xpixalign
			   * (int) srcinfo->format.bitspp / 8;
	srcshiftX += srcinfo->xpixalign;

	/* NOTE: at this point the source is ready to be presented,
	 * srcinfo->xpixalign and srcinfo->ypixalign represent additional
	 * adjustments for the DESTINATION. */

	GCDBG(GCZONE_SURF, "  adjusted surface offset (pixels) = %d,%d\n",
	      srcshiftX, srcshiftY);
	GCDBG(GCZONE_SURF, "  adjusted surface offset (bytes) = 0x%08X\n",
	      srcinfo->bytealign);

	/* Compute U/V plane offsets. */
	if ((srcinfo->format.type == BVFMT_YUV) &&
	    (srcinfo->format.cs.yuv.planecount > 1))
		set_computeyuv(srcinfo, srcshiftX, srcshiftY);

	/* Set precomputed destination adjustments based on the destination
	 * base address misalignment only. */
	dstshiftX = dstinfo->xpixalign;
	dstshiftY = dstinfo->ypixalign;

	/* Apply source adjustemnts. */
	if (srcinfo->angle == dstinfo->angle) {
		dstshiftX += srcinfo->xpixalign;
		dstshiftY += srcinfo->ypixalign;
	} else if (((srcinfo->angle + 3) % 4) == dstinfo->angle) {
		dstshiftY += srcinfo->xpixalign;
	} else if (((srcinfo->angle + 1) % 4) == dstinfo->angle) {
		dstshiftX += srcinfo->ypixalign;
	}

	/* Compute the destination surface offset in bytes. */
	dstbyteshift = dstshiftY * (int) dstinfo->geom->virtstride
		     + dstshiftX * (int) dstinfo->format.bitspp / 8;

	/* Compute the destination offset in pixels needed to compensate
	 * for the surface base address misalignment if any. If dstpixalign
	 * comes out anything other than zero, multisource blit cannot be
	 * performed. */
	dstpixalign = get_pixel_offset(dstinfo, dstbyteshift);

	GCDBG(GCZONE_SURF, "destination surface:\n");
	GCDBG(GCZONE_SURF, "  surface offset (pixels) = %d,%d\n",
	      dstshiftX, dstshiftY);
	GCDBG(GCZONE_SURF, "  surface offset (bytes) = 0x%08X\n",
	      dstbyteshift);
	GCDBG(GCZONE_SURF, "  realignment = %d\n",
	      dstpixalign);

	if ((dstpixalign != 0) ||
	    ((srcinfo->xpixalign != 0) && (srcinfo->angle == dstinfo->angle))) {
		/* Adjust the destination to match the source geometry. */
		switch (srcinfo->angle) {
		case ROT_ANGLE_0:
			/* Adjust coordinates. */
			srcclipped.left -= srcshiftX;
			srcclipped.top  -= srcshiftY;

			/* Determine source size. */
			srcsurfwidth = srcinfo->geom->width
				     - srcinfo->xpixalign;
			srcsurfheight = srcinfo->geom->height;
			break;

		case ROT_ANGLE_90:
			/* Adjust top coordinate. */
			srcclipped.top -= srcshiftX;

			/* Determine source size. */
			srcsurfwidth = srcinfo->geom->height
				     - srcinfo->xpixalign;
			srcsurfheight = srcinfo->geom->width;
			break;

		case ROT_ANGLE_180:
			/* Determine source size. */
			srcsurfwidth = srcinfo->geom->width
				     - srcinfo->xpixalign;
			srcsurfheight = srcinfo->geom->height;
			break;

		case ROT_ANGLE_270:
			/* Adjust coordinates. */
			srcclipped.left -= srcshiftY;

			/* Determine source size. */
			srcsurfwidth = srcinfo->geom->height
				     - srcinfo->xpixalign;
			srcsurfheight = srcinfo->geom->width;
			break;

		default:
			srcsurfwidth = 0;
			srcsurfheight = 0;
		}

		GCDBG(GCZONE_SURF, "srcrect origin = %d,%d\n",
		      srcclipped.left, srcclipped.top);
		GCDBG(GCZONE_SURF, "source physical size = %dx%d\n",
		      srcsurfwidth, srcsurfheight);

		/* Overwrite destination byte offset. */
		dstbyteshift = dstinfo->bytealign;

		/* No adjustment necessary for single-source. */
		dstoffsetX = 0;
		dstoffsetY = 0;

		/* Set the physical destination size. */
		physwidth = dstinfo->physwidth;
		physheight = dstinfo->physheight;

		/* Disable multi source for the cases where the destination
		 * and the source address alignments do not match. */
		multisrc = 0;
		GCDBG(GCZONE_SURF, "multi-source disabled.\n");
	} else {
		/* Source origin is not used in multi-source setup. */
		srcclipped.left = 0;
		srcclipped.top = 0;

		/* Adjust the destination to match the source geometry. */
		switch (srcinfo->angle) {
		case ROT_ANGLE_0:
			/* Adjust the destination horizontally. */
			dstoffsetX = srcinfo->xpixalign;
			dstoffsetY = srcinfo->ypixalign;

			/* Apply the source alignment. */
			if ((dstinfo->angle % 2) == 0) {
				physwidth  = dstinfo->physwidth
					   - srcinfo->xpixalign;
				physheight = dstinfo->physheight
					   - srcinfo->ypixalign;
			} else {
				physwidth  = dstinfo->physwidth
					   - srcinfo->ypixalign;
				physheight = dstinfo->physheight
					   - srcinfo->xpixalign;
			}
			break;

		case ROT_ANGLE_90:
			/* Adjust the destination vertically. */
			dstoffsetX = srcinfo->ypixalign;
			dstoffsetY = srcinfo->xpixalign;

			/* Apply the source alignment. */
			if ((dstinfo->angle % 2) == 0) {
				physwidth  = dstinfo->physwidth
					   - srcinfo->ypixalign;
				physheight = dstinfo->physheight
					   - srcinfo->xpixalign;
			} else {
				physwidth  = dstinfo->physwidth
					   - srcinfo->xpixalign;
				physheight = dstinfo->physheight
					   - srcinfo->ypixalign;
			}
			break;

		case ROT_ANGLE_180:
			/* No adjustment necessary. */
			dstoffsetX = 0;
			dstoffsetY = 0;

			/* Apply the source alignment. */
			if ((dstinfo->angle % 2) == 0) {
				physwidth  = dstinfo->physwidth
					   - srcinfo->xpixalign;
				physheight = dstinfo->physheight
					   - srcinfo->ypixalign;
			} else {
				physwidth  = dstinfo->physwidth
					   - srcinfo->ypixalign;
				physheight = dstinfo->physheight
					   - srcinfo->xpixalign;
			}
			break;

		case ROT_ANGLE_270:
			/* No adjustment necessary. */
			dstoffsetX = 0;
			dstoffsetY = 0;

			/* Apply the source alignment. */
			if ((dstinfo->angle % 2) == 0) {
				physwidth  = dstinfo->physwidth
					   - srcinfo->ypixalign;
				physheight = dstinfo->physheight
					   - srcinfo->xpixalign;
			} else {
				physwidth  = dstinfo->physwidth
					   - srcinfo->xpixalign;
				physheight = dstinfo->physheight
					   - srcinfo->ypixalign;
			}
			break;

		default:
			physwidth = 0;
			physheight = 0;
			dstoffsetX = 0;
			dstoffsetY = 0;
		}

		/* Source geometry is now the same as the destination. */
		if (orthogonal) {
			srcsurfwidth = physheight;
			srcsurfheight = physwidth;
		} else {
			srcsurfwidth = physwidth;
			srcsurfheight = physheight;
		}

		/* Enable multi-source. */
		multisrc = 1;
		GCDBG(GCZONE_SURF, "multi-source enabled.\n");
	}

	/* Misaligned source may cause the destination parameters
	 * to change, verify whether this has happened. */
	if ((batch->dstbyteshift != dstbyteshift) ||
	    (batch->dstphyswidth != physwidth) ||
	    (batch->dstphysheight != physheight) ||
	    (batch->dstoffsetX != dstoffsetX) ||
	    (batch->dstoffsetY != dstoffsetY)) {
		/* Set new values. */
		batch->dstbyteshift = dstbyteshift;
		batch->dstphyswidth = physwidth;
		batch->dstphysheight = physheight;
		batch->dstoffsetX = dstoffsetX;
		batch->dstoffsetY = dstoffsetY;

		/* Now we need to end the current batch and program
		 * the hardware with the new destination. */
		batch->batchflags |= BVBATCH_DST;
	}

	/* Check if we need to finalize existing batch. */
	if ((batch->batchend != do_blit_end) ||
	    (batch->op.blit.srccount == 4) ||
	    (batch->op.blit.multisrc == 0) ||
	    (multisrc == 0) ||
	    ((batch->batchflags & (BVBATCH_DST |
				   BVBATCH_CLIPRECT |
				   BVBATCH_DESTRECT)) != 0)) {
		/* Finalize existing batch if any. */
		bverror = batch->batchend(bvbltparams, batch);
		if (bverror != BVERR_NONE)
			goto exit;

		/* Blit batch. */
		batch->batchend = do_blit_end;

		/* Initialize the new batch. */
		gcblit = &batch->op.blit;
		gcblit->blockenable = 0;
		gcblit->srccount = 0;
		gcblit->multisrc = multisrc;

		/* Set the destination format. */
		gcblit->format  = dstinfo->format.format;
		gcblit->swizzle = dstinfo->format.swizzle;

		/* Set the destination coordinates. */
		gcblit->dstrect.left   = batch->dstadjusted.left   - dstoffsetX;
		gcblit->dstrect.top    = batch->dstadjusted.top    - dstoffsetY;
		gcblit->dstrect.right  = batch->dstadjusted.right  - dstoffsetX;
		gcblit->dstrect.bottom = batch->dstadjusted.bottom - dstoffsetY;

		/* Map the destination. */
		bverror = do_map(dstinfo->buf.desc, batch, &dstmap);
		if (bverror != BVERR_NONE) {
			bvbltparams->errdesc = gccontext->bverrorstr;
			goto exit;
		}

		/* Set the new destination. */
		bverror = set_dst(bvbltparams, batch, dstmap);
		if (bverror != BVERR_NONE)
			goto exit;

		/* Reset the modified flag. */
		batch->batchflags &= ~(BVBATCH_DST |
				       BVBATCH_CLIPRECT |
				       BVBATCH_DESTRECT);
	}

	/* Map the source. */
	bverror = do_map(srcinfo->buf.desc, batch, &srcmap);
	if (bverror != BVERR_NONE) {
		bvbltparams->errdesc = gccontext->bverrorstr;
		goto exit;
	}

	/***********************************************************************
	** Configure source.
	*/

	/* We need to walk in blocks if the source and the destination
	 * surfaces are orthogonal to each other. */
	batch->op.blit.blockenable |= orthogonal;

	/* Shortcut to the register index. */
	index = batch->op.blit.srccount;

	/* Set surface parameters. */
	if (index == 0) {
		/* Allocate command buffer. */
		bverror = claim_buffer(bvbltparams, batch,
				       sizeof(struct gcmosrc0),
				       (void **) &gcmosrc0);
		if (bverror != BVERR_NONE)
			goto exit;

		add_fixup(bvbltparams, batch, &gcmosrc0->address,
			  srcinfo->bytealign);

		gcmosrc0->config_ldst = gcmosrc0_config_ldst;
		gcmosrc0->address = GET_MAP_HANDLE(srcmap);
		gcmosrc0->stride = srcinfo->geom->virtstride;
		gcmosrc0->rotation.raw = 0;
		gcmosrc0->rotation.reg.surf_width = srcsurfwidth;
		gcmosrc0->config.raw = 0;
		gcmosrc0->config.reg.swizzle = srcinfo->format.swizzle;
		gcmosrc0->config.reg.format = srcinfo->format.format;
		gcmosrc0->origin.reg.x = srcclipped.left;
		gcmosrc0->origin.reg.y = srcclipped.top;
		gcmosrc0->size.reg = gcregsrcsize_max;

		gcmosrc0->rotation_ldst = gcmosrc0_rotation_ldst;
		gcmosrc0->rotationheight.reg.height = srcsurfheight;
		gcmosrc0->rotationangle.raw = 0;
		gcmosrc0->rotationangle.reg.src = rotencoding[srcinfo->angle];
		gcmosrc0->rotationangle.reg.dst = rotencoding[dstinfo->angle];
		gcmosrc0->rotationangle.reg.src_mirror = srcinfo->mirror;
		gcmosrc0->rotationangle.reg.dst_mirror = GCREG_MIRROR_NONE;

		gcmosrc0->rop_ldst = gcmosrc0_rop_ldst;
		gcmosrc0->rop.raw = 0;
		gcmosrc0->rop.reg.type = GCREG_ROP_TYPE_ROP3;
		gcmosrc0->rop.reg.fg = (unsigned char) srcinfo->rop;

		gcmosrc0->mult_ldst = gcmosrc0_mult_ldst;
		gcmosrc0->mult.raw = 0;
		gcmosrc0->mult.reg.srcglobalpremul
		= GCREG_COLOR_MULTIPLY_MODES_SRC_GLOBAL_PREMULTIPLY_DISABLE;

		if (srcinfo->format.premultiplied)
			gcmosrc0->mult.reg.srcpremul
			= GCREG_COLOR_MULTIPLY_MODES_SRC_PREMULTIPLY_DISABLE;
		else
			gcmosrc0->mult.reg.srcpremul
			= GCREG_COLOR_MULTIPLY_MODES_SRC_PREMULTIPLY_ENABLE;

		if (dstinfo->format.premultiplied) {
			gcmosrc0->mult.reg.dstpremul
			= GCREG_COLOR_MULTIPLY_MODES_SRC_PREMULTIPLY_DISABLE;

			gcmosrc0->mult.reg.dstdemul
			= GCREG_COLOR_MULTIPLY_MODES_DST_DEMULTIPLY_DISABLE;
		} else {
			gcmosrc0->mult.reg.dstpremul
			= GCREG_COLOR_MULTIPLY_MODES_SRC_PREMULTIPLY_ENABLE;

			gcmosrc0->mult.reg.dstdemul
			= GCREG_COLOR_MULTIPLY_MODES_DST_DEMULTIPLY_ENABLE;
		}

		/* Program blending. */
		bverror = set_blending(bvbltparams, batch, srcinfo);
		if (bverror != BVERR_NONE)
			goto exit;

		/* Program YUV source. */
		if (srcinfo->format.type == BVFMT_YUV) {
			bverror = set_yuvsrc(bvbltparams, batch,
					     srcinfo, srcmap);
			if (bverror != BVERR_NONE)
				goto exit;
		}
	} else {
		/* Allocate command buffer. */
		bverror = claim_buffer(bvbltparams, batch,
				       sizeof(struct gcmosrc),
				       (void **) &gcmosrc);
		if (bverror != BVERR_NONE)
			goto exit;

		add_fixup(bvbltparams, batch, &gcmosrc->address,
			  srcinfo->bytealign);

		gcmosrc->address_ldst = gcmosrc_address_ldst[index];
		gcmosrc->address = GET_MAP_HANDLE(srcmap);
		gcmosrc->stride_ldst = gcmosrc_stride_ldst[index];
		gcmosrc->stride = srcinfo->geom->virtstride;

		gcmosrc->rotation_ldst = gcmosrc_rotation_ldst[index];
		gcmosrc->rotation.raw = 0;
		gcmosrc->rotation.reg.surf_width = srcsurfwidth;

		gcmosrc->config_ldst = gcmosrc_config_ldst[index];
		gcmosrc->config.raw = 0;
		gcmosrc->config.reg.swizzle = srcinfo->format.swizzle;
		gcmosrc->config.reg.format = srcinfo->format.format;

		gcmosrc->origin_ldst = gcmosrc_origin_ldst[index];
		gcmosrc->origin.reg.x = srcclipped.left;
		gcmosrc->origin.reg.y = srcclipped.top;

		gcmosrc->size_ldst = gcmosrc_size_ldst[index];
		gcmosrc->size.reg = gcregsrcsize_max;

		gcmosrc->rotationheight_ldst
			= gcmosrc_rotationheight_ldst[index];
		gcmosrc->rotationheight.reg.height = srcsurfheight;

		gcmosrc->rotationangle_ldst
			= gcmosrc_rotationangle_ldst[index];
		gcmosrc->rotationangle.raw = 0;
		gcmosrc->rotationangle.reg.src = rotencoding[srcinfo->angle];
		gcmosrc->rotationangle.reg.dst = rotencoding[dstinfo->angle];
		gcmosrc->rotationangle.reg.src_mirror = srcinfo->mirror;
		gcmosrc->rotationangle.reg.dst_mirror = GCREG_MIRROR_NONE;

		gcmosrc->rop_ldst = gcmosrc_rop_ldst[index];
		gcmosrc->rop.raw = 0;
		gcmosrc->rop.reg.type = GCREG_ROP_TYPE_ROP3;
		gcmosrc->rop.reg.fg = (unsigned char) srcinfo->rop;

		gcmosrc->mult_ldst = gcmosrc_mult_ldst[index];
		gcmosrc->mult.raw = 0;
		gcmosrc->mult.reg.srcglobalpremul
		= GCREG_COLOR_MULTIPLY_MODES_SRC_GLOBAL_PREMULTIPLY_DISABLE;

		if (srcinfo->format.premultiplied)
			gcmosrc->mult.reg.srcpremul
			= GCREG_COLOR_MULTIPLY_MODES_SRC_PREMULTIPLY_DISABLE;
		else
			gcmosrc->mult.reg.srcpremul
			= GCREG_COLOR_MULTIPLY_MODES_SRC_PREMULTIPLY_ENABLE;

		if (dstinfo->format.premultiplied) {
			gcmosrc->mult.reg.dstpremul
			= GCREG_COLOR_MULTIPLY_MODES_SRC_PREMULTIPLY_DISABLE;

			gcmosrc->mult.reg.dstdemul
			= GCREG_COLOR_MULTIPLY_MODES_DST_DEMULTIPLY_DISABLE;
		} else {
			gcmosrc->mult.reg.dstpremul
			= GCREG_COLOR_MULTIPLY_MODES_SRC_PREMULTIPLY_ENABLE;

			gcmosrc->mult.reg.dstdemul
			= GCREG_COLOR_MULTIPLY_MODES_DST_DEMULTIPLY_ENABLE;
		}

		/* Program blending. */
		bverror = set_blending_index(bvbltparams, batch,
					     srcinfo, index);
		if (bverror != BVERR_NONE)
			goto exit;

		/* Program YUV source. */
		if (srcinfo->format.type == BVFMT_YUV) {
			bverror = set_yuvsrc_index(bvbltparams, batch,
						   srcinfo, srcmap, index);
			if (bverror != BVERR_NONE)
				goto exit;
		}
	}

	batch->op.blit.srccount += 1;

exit:
	GCEXITARG(GCZONE_BLIT, "bv%s = %d\n",
		  (bverror == BVERR_NONE) ? "result" : "error", bverror);
	return bverror;
}