guestrendering/guestopenvg/src/vgmask.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: 14
diff changeset
     1
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
     2
// All rights reserved.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
     3
// This component and the accompanying materials are made available
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
     5
// which accompanies this distribution, and is available
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
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: 14
diff changeset
     7
//
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
     8
// Initial Contributors:
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
     9
// Nokia Corporation - initial contribution.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    10
//
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    11
// Contributors:
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    12
//
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    13
// Description:
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    14
// Client-side state information for Open VG handle based objects
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    15
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    16
#include "vgstate.h"
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    17
#include "remotefunctioncall.h"
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    18
#include "openvgrfc.h"
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    19
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    20
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    21
/////////////////////////////////////////////////////////////////////////////////////////////
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    22
// CVgMaskLayerInfo
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    23
/////////////////////////////////////////////////////////////////////////////////////////////
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    24
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    25
CVgMaskLayerInfo* CVgMaskLayerInfo::New(VGint aWidth, VGint aHeight)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    26
	{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    27
	RHeap* clientHeap = CVghwUtils::SwitchToVghwHeap();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    28
	CVgMaskLayerInfo* self = new CVgMaskLayerInfo(aWidth, aHeight);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    29
	CVghwUtils::SwitchFromVghwHeap(clientHeap);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    30
	return self;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    31
	}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    32
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    33
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    34
CVgMaskLayerInfo::~CVgMaskLayerInfo()
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    35
	{}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    36
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    37
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    38
CVgMaskLayerInfo::CVgMaskLayerInfo(VGint aWidth, VGint aHeight) :
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    39
		CVgImageBase(EVgHandleForMaskLayer, aWidth, aHeight)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    40
	{}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    41
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    42
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    43
TBool CVgMaskLayerInfo::DestroyObject(MVgContext& aVgContext)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    44
	{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    45
	VGPANIC_ASSERT_DEBUG(iIsDestroyed, EVgPanicTemp);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    46
	OPENVG_TRACE("  CVgMaskLayerInfo::DestroyObject HostHandle=0x%x", iHostHandle);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    47
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    48
	if (iHostHandle)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    49
		{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    50
		RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    51
		vgApiData.Init(OpenVgRFC::EvgDestroyMaskLayer, RemoteFunctionCallData::EOpRequest);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    52
		vgApiData.AppendParam(iHostHandle);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    53
		aVgContext.ExecuteVgCommand(vgApiData);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    54
		}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    55
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    56
	return ETrue;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    57
	}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    58
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    59
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    60
VGint CVgMaskLayerInfo::GetParameterVectorSize(MVgContext& aVgContext, VGint)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    61
	{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    62
	aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); // VGMasks do not have any parameters
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    63
	return 0;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    64
	}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    65
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    66
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    67
void CVgMaskLayerInfo::FillMaskLayer(MVgContext& aVgContext, VGint aX, VGint aY, VGint aWidth, VGint aHeight, VGfloat aValue)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    68
	{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    69
	if ( (aValue < 0.0f) || (aValue > 1.0f) )
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    70
		{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    71
		aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    72
		}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    73
	else
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    74
		{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    75
		RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    76
		vgApiData.Init(OpenVgRFC::EvgFillMaskLayer, RemoteFunctionCallData::EOpRequest);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    77
		vgApiData.AppendParam(iHostHandle);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    78
		vgApiData.AppendParam(aX);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    79
		vgApiData.AppendParam(aY);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    80
		vgApiData.AppendParam(aWidth);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    81
		vgApiData.AppendParam(aHeight);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    82
		vgApiData.AppendParam(aValue);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    83
		aVgContext.ExecuteVgCommand(vgApiData);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    84
		}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    85
	}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    86
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    87
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    88
void CVgMaskLayerInfo::CopyMask(MVgContext& aVgContext, VGint aSx, VGint aSy, VGint aDx, VGint aDy, VGint aWidth, VGint aHeight)
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    89
	{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    90
	// **** Desirable: check maskLayer is compatible with the current surface mask
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    91
	RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    92
	vgApiData.Init(OpenVgRFC::EvgCopyMask, RemoteFunctionCallData::EOpRequest);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    93
	vgApiData.AppendParam(iHostHandle);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    94
	vgApiData.AppendParam(aSx);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    95
	vgApiData.AppendParam(aSy);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    96
	vgApiData.AppendParam(aDx);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    97
	vgApiData.AppendParam(aDy);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    98
	vgApiData.AppendParam(aWidth);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
    99
	vgApiData.AppendParam(aHeight);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
   100
	aVgContext.ExecuteVgCommand(vgApiData);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
   101
	}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
   102
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
   103
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 14
diff changeset
   104
// end of file vgmask.cpp