guestrendering/guestopenvgu/src/openvgu.cpp
author Matt Plumtree <matt.plumtree@nokia.com>
Mon, 15 Nov 2010 09:56:25 +0000
branchbug235_bringup_0
changeset 77 b0395290e61f
parent 24 a3f46bb01be2
permissions -rwxr-xr-x
Ensure OpenGL ES 2.0 C functions use C signatures in C++ builds (fixes VS builds)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
     1
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
     2
// All rights reserved.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
     3
// This component and the accompanying materials are made available
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
     5
// which accompanies this distribution, and is available
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
     7
//
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
     8
// Initial Contributors:
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
     9
// Nokia Corporation - initial contribution.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    10
//
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    11
// Contributors:
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    12
//
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    13
// Description:
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    14
// Implementation of OpenVGU stub functions
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    15
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    16
#include "vghwutils.h"
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    17
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    18
#define __VG_OPENVG_H_
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    19
#include <VG/1.1/openvg.h>
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    20
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    21
#include "openvgrfc.h"
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    22
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    23
class RemoteFunctionCall;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    24
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    25
// tracing
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    26
#ifdef _DEBUG
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    27
	#include <e32debug.h>
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    28
    #define OPENVGU_TRACE(fmt, args...) RDebug::Printf(fmt, ##args)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    29
#else
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    30
    #define OPENVGU_TRACE(fmt, args...)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    31
#endif
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    32
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    33
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    34
extern "C" {
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    35
/*
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    36
 Note: Comments at the start of each Open VG api are adapted from the Open VG 1.1 specification.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    37
 The text has been chosen/adapted to give a helpful overview of the function, and the errors
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    38
 that it may generate.  For more details and diagrams see the full Open VG specification.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    39
 */
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    40
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    41
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    42
/*
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    43
 Append a line segment to a path.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    44
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    45
 ERRORS
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    46
   VGU_BAD_HANDLE_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    47
   – if path is not a valid path handle, or is not shared with the current context
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    48
   VGU_PATH_CAPABILITY_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    49
   – if VG_PATH_CAPABILITY_APPEND_TO is not enabled for path
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    50
 */
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    51
EXPORT_C VGUErrorCode
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    52
     vguLine(VGPath path,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    53
        VGfloat x0, VGfloat y0,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    54
        VGfloat x1, VGfloat y1)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    55
    {
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    56
	OPENVGU_TRACE("vguLine path=%d x0=0x%x, y0=0x%x, x1=0x%x, y1=0x%x", path, x0, y0, x1, y1);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    57
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    58
	MVgContext* vgContext = CVghwUtils::VgContext();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    59
	VGUErrorCode error = VGU_OUT_OF_MEMORY_ERROR;  // nearest VGU has to an Invalid Context error
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    60
	if (vgContext)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    61
		{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    62
		RemoteFunctionCallData rfcdata; OpenVgRFC vguApiData(rfcdata);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    63
		vguApiData.Init(OpenVgRFC::EvguLine);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    64
		vguApiData.AppendParam(path);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    65
		vguApiData.AppendParam(x0);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    66
		vguApiData.AppendParam(y0);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    67
		vguApiData.AppendParam(x1);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    68
		vguApiData.AppendParam(y1);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    69
		// TODO return type specific functions for VGU operations
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    70
		vgContext->ExecuteVgCommand(vguApiData);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    71
		error = (VGUErrorCode)vguApiData.ReturnValue();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    72
		}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    73
	return error;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    74
    }
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    75
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    76
/*
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    77
 Append a polyline (connected sequence of line segments) or polygon to a path.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    78
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    79
 ERRORS
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    80
   VGU_BAD_HANDLE_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    81
   – if path is not a valid path handle, or is not shared with the current context
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    82
   VGU_PATH_CAPABILITY_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    83
   – if VG_PATH_CAPABILITY_APPEND_TO is not enabled for path
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    84
   VGU_ILLEGAL_ARGUMENT_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    85
   – if points is NULL
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    86
   – if points is not properly aligned
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    87
   – if count is less than or equal to 0
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    88
 */
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    89
EXPORT_C VGUErrorCode
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    90
     vguPolygon(VGPath path,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    91
        const VGfloat * points,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    92
        VGint count,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    93
        VGboolean closed)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    94
    {
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    95
	OPENVGU_TRACE("vguPolygon path=%d, points=0x%x, count=%d, closed=%d", path, points, count, closed);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    96
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    97
	MVgContext* vgContext = CVghwUtils::VgContext();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    98
	VGUErrorCode error = VGU_OUT_OF_MEMORY_ERROR;  // nearest VGU has to an Invalid Context error
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
    99
	if (vgContext)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   100
		{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   101
		if ( (points == NULL) || (count <= 0) || (3ul & (unsigned)points) )
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   102
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   103
			error = VGU_ILLEGAL_ARGUMENT_ERROR;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   104
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   105
		else
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   106
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   107
			RemoteFunctionCallData rfcdata; OpenVgRFC vguApiData(rfcdata);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   108
			vguApiData.Init(OpenVgRFC::EvguPolygon);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   109
			vguApiData.AppendParam(path);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   110
			vguApiData.AppendParam(count);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   111
			vguApiData.AppendParam(closed);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   112
			vguApiData.AppendVector(points, count * 2);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   113
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   114
			vgContext->ExecuteVgCommand(vguApiData);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   115
			error = (VGUErrorCode)vguApiData.ReturnValue();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   116
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   117
		}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   118
	return error;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   119
    }
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   120
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   121
/*
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   122
 Append an axis-aligned rectangle with its lower-left corner at (x, y) and
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   123
 a given width and height to a path.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   124
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   125
 ERRORS
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   126
   VGU_BAD_HANDLE_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   127
   – if path is not a valid path handle, or is not shared with the current context
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   128
   VGU_PATH_CAPABILITY_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   129
   – if VG_PATH_CAPABILITY_APPEND_TO is not enabled for path
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   130
   VGU_ILLEGAL_ARGUMENT_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   131
   – if width or height are less than or equal to 0
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   132
 */
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   133
EXPORT_C VGUErrorCode
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   134
     vguRect(VGPath path,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   135
        VGfloat x, VGfloat y,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   136
        VGfloat width, VGfloat height)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   137
    {
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   138
	OPENVGU_TRACE("vguRect path=%d, x=0x%x, y=0x%x, width=0x%x, height=0x%x", path, x, y, width, height);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   139
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   140
	MVgContext* vgContext = CVghwUtils::VgContext();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   141
	VGUErrorCode error = VGU_OUT_OF_MEMORY_ERROR;  // nearest VGU has to an Invalid Context error
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   142
	if (vgContext)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   143
		{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   144
		if ( (width <= 0) || (height <= 0) )
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   145
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   146
			error = VGU_ILLEGAL_ARGUMENT_ERROR;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   147
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   148
		else
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   149
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   150
			RemoteFunctionCallData rfcdata; OpenVgRFC vguApiData(rfcdata);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   151
			vguApiData.Init(OpenVgRFC::EvguRect);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   152
			vguApiData.AppendParam(path);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   153
			vguApiData.AppendParam(x);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   154
			vguApiData.AppendParam(y);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   155
			vguApiData.AppendParam(width);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   156
			vguApiData.AppendParam(height);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   157
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   158
			vgContext->ExecuteVgCommand(vguApiData);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   159
			error = (VGUErrorCode)vguApiData.ReturnValue();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   160
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   161
		}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   162
	return error;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   163
    }
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   164
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   165
/*
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   166
 Append an axis-aligned round-cornered rectangle with the lower-left corner of
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   167
 its rectangular bounding box at (x, y) and a given width, height, arcWidth,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   168
 and arcHeight to a path.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   169
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   170
 ERRORS
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   171
   VGU_BAD_HANDLE_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   172
   – if path is not a valid path handle, or is not shared with the current context
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   173
   VGU_PATH_CAPABILITY_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   174
   – if VG_PATH_CAPABILITY_APPEND_TO is not enabled for path
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   175
   VGU_ILLEGAL_ARGUMENT_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   176
   – if width or height is less than or equal to 0
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   177
 */
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   178
EXPORT_C VGUErrorCode
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   179
     vguRoundRect(VGPath path,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   180
        VGfloat x, VGfloat y,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   181
        VGfloat width,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   182
        VGfloat height,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   183
        VGfloat arcWidth,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   184
        VGfloat arcHeight)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   185
    {
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   186
	OPENVGU_TRACE("vguRoundRect path=%d, x=0x%x, y=0x%x, width=0x%x, height=0x%x, arcWidth=0x%x, arcHeight=0x%x",
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   187
			path, x, y, width, height, arcWidth, arcHeight);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   188
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   189
	MVgContext* vgContext = CVghwUtils::VgContext();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   190
	VGUErrorCode error = VGU_OUT_OF_MEMORY_ERROR;  // nearest VGU has to an Invalid Context error
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   191
	if (vgContext)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   192
		{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   193
		if ( (width <= 0) || (height <= 0) )
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   194
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   195
			error = VGU_ILLEGAL_ARGUMENT_ERROR;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   196
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   197
		else
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   198
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   199
			RemoteFunctionCallData rfcdata; OpenVgRFC vguApiData(rfcdata);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   200
			vguApiData.Init(OpenVgRFC::EvguRoundRect);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   201
			vguApiData.AppendParam(path);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   202
			vguApiData.AppendParam(x);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   203
			vguApiData.AppendParam(y);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   204
			vguApiData.AppendParam(width);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   205
			vguApiData.AppendParam(height);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   206
			vguApiData.AppendParam(arcWidth);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   207
			vguApiData.AppendParam(arcHeight);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   208
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   209
			vgContext->ExecuteVgCommand(vguApiData);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   210
			error = (VGUErrorCode)vguApiData.ReturnValue();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   211
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   212
		}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   213
	return error;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   214
    }
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   215
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   216
/*
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   217
 Append an axis-aligned ellipse to a path. The center of the ellipse is given by
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   218
 (cx, cy) and the dimensions of the axis-aligned rectangle enclosing the ellipse are
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   219
 given by width and height. The ellipse begins at (cx + width/2, cy) and is stroked
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   220
 as two equal counter-clockwise arcs.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   221
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   222
 ERRORS
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   223
   VGU_BAD_HANDLE_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   224
   – if path is not a valid path handle, or is not shared with the current context
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   225
   VGU_PATH_CAPABILITY_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   226
   – if VG_PATH_CAPABILITY_APPEND_TO is not enabled for path
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   227
   VGU_ILLEGAL_ARGUMENT_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   228
   – if width or height is less than or equal to 0
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   229
 */
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   230
EXPORT_C VGUErrorCode
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   231
     vguEllipse(VGPath path,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   232
        VGfloat cx, VGfloat cy,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   233
        VGfloat width,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   234
        VGfloat height)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   235
    {
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   236
	OPENVGU_TRACE("vguEllipse path=%d, cx=0x%x, cy=0x%x, width=0x%x, height=0x%x", path, cx, cy, width, height);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   237
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   238
	MVgContext* vgContext = CVghwUtils::VgContext();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   239
	VGUErrorCode error = VGU_OUT_OF_MEMORY_ERROR;  // nearest VGU has to an Invalid Context error
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   240
	if (vgContext)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   241
		{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   242
		if ( (width <= 0) || (height <= 0) )
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   243
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   244
			error = VGU_ILLEGAL_ARGUMENT_ERROR;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   245
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   246
		else
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   247
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   248
			RemoteFunctionCallData rfcdata; OpenVgRFC vguApiData(rfcdata);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   249
			vguApiData.Init(OpenVgRFC::EvguEllipse);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   250
			vguApiData.AppendParam(path);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   251
			vguApiData.AppendParam(cx);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   252
			vguApiData.AppendParam(cy);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   253
			vguApiData.AppendParam(width);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   254
			vguApiData.AppendParam(height);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   255
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   256
			vgContext->ExecuteVgCommand(vguApiData);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   257
			error = (VGUErrorCode)vguApiData.ReturnValue();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   258
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   259
		}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   260
	return error;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   261
    }
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   262
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   263
/*
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   264
 Append an elliptical arc to a path, possibly along with one or two line segments,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   265
 according to the arcType parameter. The startAngle and angleExtent parameters are
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   266
 given in degrees, proceeding counter-clockwise from the positive X axis. The arc
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   267
 is defined on the unit circle, then scaled by the width and height of the ellipse.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   268
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   269
 ERRORS
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   270
   VGU_BAD_HANDLE_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   271
   – if path is not a valid path handle, or is not shared with the current context
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   272
   VGU_PATH_CAPABILITY_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   273
   – if VG_PATH_CAPABILITY_APPEND_TO is not enabled for path
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   274
   VGU_ILLEGAL_ARGUMENT_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   275
   – if width or height is less than or equal to 0
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   276
   – if arcType is not one of the values from the VGUArcType enumeration
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   277
 */
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   278
EXPORT_C VGUErrorCode
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   279
     vguArc(VGPath path,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   280
        VGfloat x, VGfloat y,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   281
        VGfloat width, VGfloat height,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   282
        VGfloat startAngle,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   283
        VGfloat angleExtent,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   284
        VGUArcType arcType)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   285
    {
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   286
	OPENVGU_TRACE("vguArc path=%d, x=0x%x, y=0x%x, width=0x%x, height=0x%x, startAngle=0x%x, angleExtent=0x%x, arcType=%d",
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   287
			path, x, y, width, height, startAngle, angleExtent, arcType);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   288
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   289
	MVgContext* vgContext = CVghwUtils::VgContext();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   290
	VGUErrorCode error = VGU_OUT_OF_MEMORY_ERROR;  // nearest VGU has to an Invalid Context error
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   291
	if (vgContext)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   292
		{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   293
		const unsigned int n_posinf = 0x7f800000u;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   294
		const unsigned int n_neginf = 0xff800000u;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   295
		VGfloat posinf = *(VGfloat*)&n_posinf;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   296
		VGfloat neginf = *(VGfloat*)&n_neginf;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   297
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   298
		if ( (width <= 0) || (height <= 0) || ( (arcType != VGU_ARC_OPEN) && (arcType == VGU_ARC_CHORD) && (arcType == VGU_ARC_PIE) ) )
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   299
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   300
			error = VGU_ILLEGAL_ARGUMENT_ERROR;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   301
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   302
		// Tony TODO review NaN detection; not convinced that this works
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   303
		else if ( ((x + x - x) != x) || ((y + y - y) != y) ) /* NaN's */
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   304
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   305
			error = VGU_ILLEGAL_ARGUMENT_ERROR;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   306
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   307
		else if ( ((startAngle + startAngle - startAngle) != startAngle) || ((angleExtent + angleExtent - angleExtent) != angleExtent) )
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   308
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   309
			error = VGU_ILLEGAL_ARGUMENT_ERROR;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   310
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   311
		else if ( (startAngle <= neginf) || (startAngle >= posinf) )
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   312
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   313
			error = VGU_ILLEGAL_ARGUMENT_ERROR;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   314
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   315
		else if ( (angleExtent <= neginf) || (angleExtent >= posinf) )
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   316
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   317
			error = VGU_ILLEGAL_ARGUMENT_ERROR;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   318
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   319
		else if ( (x <= neginf) || (x >= posinf) ) /*Infinity x */
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   320
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   321
			error = VGU_ILLEGAL_ARGUMENT_ERROR;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   322
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   323
		else if ( (y <= neginf) || (y >= posinf) ) /*Infinity x */
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   324
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   325
			error = VGU_ILLEGAL_ARGUMENT_ERROR;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   326
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   327
		else
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   328
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   329
			RemoteFunctionCallData rfcdata; OpenVgRFC vguApiData(rfcdata);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   330
			vguApiData.Init(OpenVgRFC::EvguArc);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   331
			vguApiData.AppendParam(path);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   332
			vguApiData.AppendParam(x);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   333
			vguApiData.AppendParam(y);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   334
			vguApiData.AppendParam(width);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   335
			vguApiData.AppendParam(height);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   336
			vguApiData.AppendParam(startAngle);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   337
			vguApiData.AppendParam(angleExtent);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   338
			vguApiData.AppendParam(arcType);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   339
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   340
			vgContext->ExecuteVgCommand(vguApiData);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   341
			error = (VGUErrorCode)vguApiData.ReturnValue();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   342
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   343
		}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   344
	return error;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   345
    }
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   346
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   347
/*
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   348
 Sets the entries of matrix to a projective transformation that maps the point
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   349
 (sx0, sy0) to (0, 0); (sx1, sy1) to (1, 0); (sx2, sy2) to (0, 1); and (sx3, sy3)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   350
 to (1, 1). If no non-degenerate matrix satisfies the constraints,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   351
 VGU_BAD_WARP_ERROR is returned and matrix is unchanged.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   352
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   353
 ERRORS
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   354
   VGU_ILLEGAL_ARGUMENT_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   355
   – if matrix is NULL
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   356
   – if matrix is not properly aligned
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   357
   VGU_BAD_WARP_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   358
   – if no non-degenerate transformation satisfies the constraints
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   359
 */
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   360
EXPORT_C VGUErrorCode
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   361
    vguComputeWarpQuadToSquare(VGfloat sx0, VGfloat sy0,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   362
        VGfloat sx1, VGfloat sy1,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   363
        VGfloat sx2, VGfloat sy2,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   364
        VGfloat sx3, VGfloat sy3,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   365
        VGfloat * matrix)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   366
    {
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   367
	OPENVGU_TRACE("vguComputeWarpQuadToSquare sx0=0x%x, sy0=0x%x, sx1=0x%x, sy1=0x%x, sx2=0x%x, sy2=0x%x, sx3=0x%x, sy3=0x%x, matrix=0x%x",
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   368
			sx0, sy0, sx1, sy1, sx2, sy2, sx3, sy3, matrix);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   369
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   370
	MVgContext* vgContext = CVghwUtils::VgContext();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   371
	VGUErrorCode error = VGU_OUT_OF_MEMORY_ERROR;  // nearest VGU has to an Invalid Context error
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   372
	if (vgContext)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   373
		{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   374
		if ( (matrix == NULL) || (3ul & (unsigned)matrix))
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   375
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   376
			error = VGU_ILLEGAL_ARGUMENT_ERROR;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   377
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   378
		else
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   379
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   380
			RemoteFunctionCallData rfcdata; OpenVgRFC vguApiData( rfcdata );
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   381
			vguApiData.Init(OpenVgRFC::EvguComputeWarpQuadToSquare);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   382
			vguApiData.AppendParam(sx0);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   383
			vguApiData.AppendParam(sy0);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   384
			vguApiData.AppendParam(sx1);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   385
			vguApiData.AppendParam(sy1);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   386
			vguApiData.AppendParam(sx2);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   387
			vguApiData.AppendParam(sy2);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   388
			vguApiData.AppendParam(sx3);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   389
			vguApiData.AppendParam(sy3);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   390
			vguApiData.AppendVector(matrix, 9, RemoteFunctionCallData::EOut);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   391
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   392
			vgContext->ExecuteVgCommand(vguApiData);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   393
			error = (VGUErrorCode)vguApiData.ReturnValue();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   394
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   395
		}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   396
	return error;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   397
    }
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   398
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   399
/*
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   400
 Sets the entries of matrix to a projective transformation that maps the point
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   401
 (0, 0) to (dx0, dy0); (1, 0) to (dx1, dy1); (0, 1) to (dx2, dy2); and (1, 1) to
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   402
 (dx3, dy3). If no non-degenerate matrix satisfies the constraints, VGU_BAD_WARP_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   403
 is returned and matrix is unchanged.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   404
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   405
 ERRORS
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   406
   VGU_ILLEGAL_ARGUMENT_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   407
   – if matrix is NULL
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   408
   – if matrix is not properly aligned
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   409
   VGU_BAD_WARP_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   410
   – if no non-degenerate transformation satisfies the constraints
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   411
 */
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   412
EXPORT_C VGUErrorCode
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   413
    vguComputeWarpSquareToQuad(VGfloat dx0, VGfloat dy0,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   414
        VGfloat dx1, VGfloat dy1,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   415
        VGfloat dx2, VGfloat dy2,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   416
        VGfloat dx3, VGfloat dy3,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   417
        VGfloat * matrix)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   418
    {
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   419
	OPENVGU_TRACE("vguComputeWarpSquareToQuad dx0=0x%x, dy0=0x%x, dx1=0x%x, dy1=0x%x, dx2=0x%x, dy2=0x%x, dx3=0x%x, dy3=0x%x, matrix=0x%x",
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   420
			dx0, dy0, dx1, dy1, dx2, dy2, dx3, dy3, matrix);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   421
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   422
	MVgContext* vgContext = CVghwUtils::VgContext();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   423
	VGUErrorCode error = VGU_OUT_OF_MEMORY_ERROR;  // nearest VGU has to an Invalid Context error
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   424
	if (vgContext)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   425
		{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   426
		if ( (matrix == NULL) || (3ul & (unsigned)matrix))
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   427
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   428
			error = VGU_ILLEGAL_ARGUMENT_ERROR;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   429
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   430
		else
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   431
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   432
			RemoteFunctionCallData rfcdata; OpenVgRFC vguApiData(rfcdata);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   433
			vguApiData.Init(OpenVgRFC::EvguComputeWarpSquareToQuad);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   434
			vguApiData.AppendParam(dx0);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   435
			vguApiData.AppendParam(dy0);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   436
			vguApiData.AppendParam(dx1);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   437
			vguApiData.AppendParam(dy1);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   438
			vguApiData.AppendParam(dx2);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   439
			vguApiData.AppendParam(dy2);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   440
			vguApiData.AppendParam(dx3);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   441
			vguApiData.AppendParam(dy3);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   442
			vguApiData.AppendVector(matrix, 9, RemoteFunctionCallData::EOut);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   443
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   444
			vgContext->ExecuteVgCommand(vguApiData);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   445
			error = (VGUErrorCode)vguApiData.ReturnValue();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   446
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   447
		}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   448
    return error;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   449
    }
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   450
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   451
/*
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   452
 Sets the entries of matrix to a projective transformation that maps the point
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   453
 (sx0, sy0) to (dx0, dy0); (sx1, sy1) to (dx1, dy1); (sx2, sy2) to (dx2, dy2);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   454
 and (sx3, sy3) to (dx3, dy3). If no non-degenerate matrix satisfies the constraints,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   455
 VGU_BAD_WARP_ERROR is returned and matrix is unchanged.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   456
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   457
 ERRORS
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   458
   VGU_ILLEGAL_ARGUMENT_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   459
   – if matrix is NULL
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   460
   – if matrix is not properly aligned
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   461
   VGU_BAD_WARP_ERROR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   462
   – if no non-degenerate transformation satisfies the constraints
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   463
 */
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   464
EXPORT_C VGUErrorCode
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   465
    vguComputeWarpQuadToQuad(VGfloat dx0, VGfloat dy0,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   466
        VGfloat dx1, VGfloat dy1,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   467
        VGfloat dx2, VGfloat dy2,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   468
        VGfloat dx3, VGfloat dy3,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   469
        VGfloat sx0, VGfloat sy0,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   470
        VGfloat sx1, VGfloat sy1,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   471
        VGfloat sx2, VGfloat sy2,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   472
        VGfloat sx3, VGfloat sy3,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   473
        VGfloat * matrix)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   474
    {
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   475
	OPENVGU_TRACE("vguComputeWarpQuadToQuad");
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   476
	MVgContext* vgContext = CVghwUtils::VgContext();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   477
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   478
	VGUErrorCode error = VGU_OUT_OF_MEMORY_ERROR;  // nearest VGU has to an Invalid Context error
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   479
	if (vgContext)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   480
		{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   481
		if ( (matrix == NULL) || (3ul & (unsigned)matrix))
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   482
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   483
			error = VGU_ILLEGAL_ARGUMENT_ERROR;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   484
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   485
		else
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   486
			{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   487
			RemoteFunctionCallData rfcdata; OpenVgRFC vguApiData(rfcdata);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   488
			vguApiData.Init(OpenVgRFC::EvguComputeWarpQuadToQuad);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   489
			vguApiData.AppendParam(dx0);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   490
			vguApiData.AppendParam(dy0);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   491
			vguApiData.AppendParam(dx1);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   492
			vguApiData.AppendParam(dy1);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   493
			vguApiData.AppendParam(dx2);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   494
			vguApiData.AppendParam(dy2);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   495
			vguApiData.AppendParam(dx3);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   496
			vguApiData.AppendParam(dy3);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   497
			vguApiData.AppendParam(sx0);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   498
			vguApiData.AppendParam(sy0);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   499
			vguApiData.AppendParam(sx1);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   500
			vguApiData.AppendParam(sy1);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   501
			vguApiData.AppendParam(sx2);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   502
			vguApiData.AppendParam(sy2);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   503
			vguApiData.AppendParam(sx3);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   504
			vguApiData.AppendParam(sy3);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   505
			vguApiData.AppendVector(matrix, 9, RemoteFunctionCallData::EOut);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   506
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   507
			vgContext->ExecuteVgCommand(vguApiData);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   508
			error = (VGUErrorCode)vguApiData.ReturnValue();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   509
			}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   510
		}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   511
	return error;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   512
    }
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   513
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 15
diff changeset
   514
} /* extern "C" */