Esempio n. 1
0
VGUErrorCode vguComputeWarpQuadToQuad(VGfloat dx0, VGfloat dy0, VGfloat dx1, VGfloat dy1, VGfloat dx2, VGfloat dy2, VGfloat dx3, VGfloat dy3, VGfloat sx0, VGfloat sy0, VGfloat sx1, VGfloat sy1, VGfloat sx2, VGfloat sy2, VGfloat sx3, VGfloat sy3, VGfloat * matrix)
{
	if(!matrix || ((ptrdiff_t)matrix) & 3)
		return VGU_ILLEGAL_ARGUMENT_ERROR;
	
	VGfloat qtos[9];
	VGUErrorCode ret1 = vguComputeWarpQuadToSquare(sx0, sy0, sx1, sy1, sx2, sy2, sx3, sy3, qtos);
	if(ret1 == VGU_BAD_WARP_ERROR)
		return VGU_BAD_WARP_ERROR;
	
	VGfloat stoq[9];
	VGUErrorCode ret2 = vguComputeWarpSquareToQuad(dx0, dy0, dx1, dy1, dx2, dy2, dx3, dy3, stoq);
	if(ret2 == VGU_BAD_WARP_ERROR)
		return VGU_BAD_WARP_ERROR;
	
	Matrix3x3 m1(qtos[0], qtos[3], qtos[6],
				 qtos[1], qtos[4], qtos[7],
				 qtos[2], qtos[5], qtos[8]);
	Matrix3x3 m2(stoq[0], stoq[3], stoq[6],
				 stoq[1], stoq[4], stoq[7],
				 stoq[2], stoq[5], stoq[8]);
	Matrix3x3 r = m2 * m1;
	
	matrix[0] = r[0][0];
	matrix[1] = r[1][0];
	matrix[2] = r[2][0];
	matrix[3] = r[0][1];
	matrix[4] = r[1][1];
	matrix[5] = r[2][1];
	matrix[6] = r[0][2];
	matrix[7] = r[1][2];
	matrix[8] = r[2][2];
	return VGU_NO_ERROR;
}
Esempio n. 2
0
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpQuadToQuad(
	VGfloat DestinationX0,
	VGfloat DestinationY0,
	VGfloat DestinationX1,
	VGfloat DestinationY1,
	VGfloat DestinationX2,
	VGfloat DestinationY2,
	VGfloat DestinationX3,
	VGfloat DestinationY3,
	VGfloat SourceX0,
	VGfloat SourceY0,
	VGfloat SourceX1,
	VGfloat SourceY1,
	VGfloat SourceX2,
	VGfloat SourceY2,
	VGfloat SourceX3,
	VGfloat SourceY3,
	VGfloat * Matrix
	)
{
	VGUErrorCode result = VGU_BAD_HANDLE_ERROR;

	vgmENTERAPI(vguComputeWarpQuadToQuad)
	{
		vgsMATRIX q2s;
		vgsMATRIX s2q;
		vgsMATRIX product;

#if gcdENABLE_PERFORMANCE_PRIOR
		gctFLOAT m1[9], m2[9];
#endif
		/* Validate the input matrix. */
		if (vgmIS_INVALID_PTR(Matrix, 4))
		{
			result = VGU_ILLEGAL_ARGUMENT_ERROR;
			break;
		}

		/* Reset matrices. */
		vgfInvalidateMatrix(&q2s);
		vgfInvalidateMatrix(&s2q);

#if gcdENABLE_PERFORMANCE_PRIOR
		result = vguComputeWarpQuadToSquare(
			SourceX0, SourceY0,
			SourceX1, SourceY1,
			SourceX2, SourceY2,
			SourceX3, SourceY3,
			m1
			);

		/* Error? */
		if (result != VGU_NO_ERROR)
		{
			break;
		}

		vgmCONVERTMAT(gctFIXED, gctFLOAT, vgmFLOAT_TO_FIXED_SPECIAL, &q2s, m1);

		result = vguComputeWarpSquareToQuad(
			DestinationX0, DestinationY0,
			DestinationX1, DestinationY1,
			DestinationX2, DestinationY2,
			DestinationX3, DestinationY3,
			m2
			);

		/* Error? */
		if (result != VGU_NO_ERROR)
		{
			break;
		}

		vgmCONVERTMAT(gctFIXED, gctFLOAT, vgmFLOAT_TO_FIXED_SPECIAL, &s2q, m2);

		/* Find the product. */
		vgfMultiplyMatrix3x3(&s2q, &q2s, &product);

		/* Set the result. */
		vgmCONVERTMAT(gctFLOAT, gctFIXED, vgmFIXED_TO_FLOAT_SPECIAL, Matrix, &product);
#else
		result = vguComputeWarpQuadToSquare(
			SourceX0, SourceY0,
			SourceX1, SourceY1,
			SourceX2, SourceY2,
			SourceX3, SourceY3,
			vgmGETMATRIXVALUES(&q2s)
			);

		/* Error? */
		if (result != VGU_NO_ERROR)
		{
			break;
		}

		result = vguComputeWarpSquareToQuad(
			DestinationX0, DestinationY0,
			DestinationX1, DestinationY1,
			DestinationX2, DestinationY2,
			DestinationX3, DestinationY3,
			vgmGETMATRIXVALUES(&s2q)
			);

		/* Error? */
		if (result != VGU_NO_ERROR)
		{
			break;
		}

		/* Find the product. */
		vgfMultiplyMatrix3x3(&s2q, &q2s, &product);

		/* Set the result. */
		gcoOS_MemCopy(
			Matrix,
			vgmGETMATRIXVALUES(&product),
			sizeof(vgtMATRIXVALUES)
			);
#endif
	}
	vgmLEAVEAPI(vguComputeWarpQuadToQuad);

	/* Return result. */
	return result;
}