os/graphics/windowing/windowserver/test/t_integ/src/t_pseudoappvganimation.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/t_integ/src/t_pseudoappvganimation.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,153 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +/**
    1.20 + @file
    1.21 + @test
    1.22 + @internalComponent
    1.23 +*/
    1.24 +
    1.25 +#include "t_pseudoappvganimation.h"
    1.26 +
    1.27 +//for the inner square
    1.28 +const TReal32 KTlx = 0;
    1.29 +const TReal32 KTly = 0;
    1.30 +const TReal32 KSzx = 60;
    1.31 +const TReal32 KSzy = 60;
    1.32 +
    1.33 +void CVgAnimation::DrawToEglL()
    1.34 +	{
    1.35 +    // clear background
    1.36 +    VGfloat bgColor[] = {0.0, 0.0, 0.0, 0.0};
    1.37 +    vgSetfv(VG_CLEAR_COLOR, 4, bgColor);
    1.38 +    vgClear(0, 0, iSurfaceSize.iWidth, iSurfaceSize.iHeight);
    1.39 +
    1.40 +	//paint creation and setting.
    1.41 +	vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER);
    1.42 +	vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_BETTER);
    1.43 +
    1.44 +	VGPaint fillPaint=vgCreatePaint();
    1.45 +	CheckVgErrorL(_L("vgCreatePaint failed"));
    1.46 +
    1.47 +	//the fill paint
    1.48 +	VGfloat fillColor[4];
    1.49 +	fillColor[0] = 0.0f/255.0f;  //blue
    1.50 +	fillColor[1] = 255.0f/255.0f; //red
    1.51 +	fillColor[2] = 0.0f/255.0f; //green
    1.52 +	fillColor[3] = 255.0f/255.0f; //alpha = required to be 1.0
    1.53 +
    1.54 +	vgSetParameteri(fillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
    1.55 +	CheckVgErrorL(_L("fillPaint VG_PAINT_TYPE failed"));
    1.56 +	vgSetParameterfv(fillPaint, VG_PAINT_COLOR, 4, fillColor);
    1.57 +	CheckVgErrorL(_L("fillPaint VG_PAINT_COLOR failed"));
    1.58 +
    1.59 +	VGPath	bgPath;
    1.60 +	bgPath= vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_S_32, 1.0f, 0.0f, 4, 4, (unsigned int)VG_PATH_CAPABILITY_ALL);
    1.61 +	CheckVgErrorL(_L("vgCreatePath failed"));
    1.62 +
    1.63 +	VGUErrorCode vguerr=vguEllipse(bgPath, KTlx, KTly, KSzx, KSzy);
    1.64 +	TestL(vguerr==VGU_NO_ERROR, _L("vguRect failed"));
    1.65 +	CheckVgErrorL(_L("vguRect failed"));
    1.66 +
    1.67 +	vgSetPaint(fillPaint, VG_FILL_PATH);
    1.68 +	CheckVgErrorL(_L("VG_FILL_PATH failed"));
    1.69 +
    1.70 +	vgLoadIdentity();
    1.71 +
    1.72 +    vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
    1.73 +	CheckVgErrorL(_L("vgLoadIdentity failed"));
    1.74 +
    1.75 +	vgTranslate(iX, iY);
    1.76 +
    1.77 +	vgDrawPath(bgPath, VG_FILL_PATH);
    1.78 +	CheckVgErrorL(_L("vgDrawPath failed"));
    1.79 +
    1.80 +	vgDestroyPath(bgPath);
    1.81 +	vgDestroyPaint(fillPaint);
    1.82 +
    1.83 +	vgFinish();
    1.84 +
    1.85 +	TInt ret=eglSwapBuffers(iDisplay,iSurface);
    1.86 +	TestL(ret,_L("eglSwapBuffers failed"));
    1.87 +	}
    1.88 +
    1.89 +void CVgAnimation::DrawL(CTestSurfaceRasterizer*  /*aSurfaceRasterizer*/, SurfaceDetails& /*aSurfDetails*/)
    1.90 +	{
    1.91 +	DrawToEglL();
    1.92 +
    1.93 +	if (iY >= iSurfaceSize.iHeight || iX >= iSurfaceSize.iWidth )
    1.94 +		{
    1.95 +		iX=0;
    1.96 +		iY=0;
    1.97 +		}
    1.98 +	else
    1.99 +		{
   1.100 +		iX+=iHorizontalRate;
   1.101 +		iY+=iVerticalRate;
   1.102 +		}
   1.103 +	}
   1.104 +
   1.105 +CVgAnimation* CVgAnimation::NewL(RWindow* aWin, const TDisplayMode& aMode, const TSize& aSurfaceSize,
   1.106 +																		  const TInt aHorizontalRate,
   1.107 +																		  const TInt aVerticalRate)
   1.108 +	{
   1.109 +	RDebug::Print(_L("Creating CVgAnimation class\n"));
   1.110 +    CVgAnimation* self = new (ELeave) CVgAnimation(aMode,aSurfaceSize,aHorizontalRate,aVerticalRate);
   1.111 +    CleanupStack::PushL(self);
   1.112 +    self->ConstructL(aWin);
   1.113 +    CleanupStack::Pop(); // self;
   1.114 +    return self;
   1.115 +	}
   1.116 +
   1.117 +CVgAnimation::CVgAnimation(const TDisplayMode& aMode, const TSize& aSurfaceSize, const TInt aHorizontalRate, const TInt aVerticalRate)
   1.118 +: CEglBase(aMode,aSurfaceSize,aHorizontalRate,aVerticalRate)
   1.119 +	{
   1.120 +	}
   1.121 +
   1.122 +void CVgAnimation::ConstructL(RWindow* aWin)
   1.123 +	{
   1.124 +	BaseConstructL(aWin);
   1.125 +
   1.126 +	// eglBindAPI
   1.127 +	TInt ret = eglBindAPI(EGL_OPENVG_API);
   1.128 +	TestL(ret, _L("eglBindAPI failed"));
   1.129 +
   1.130 +	__ASSERT_DEBUG(iUseConfig>0, User::Panic(_L("CVgAnimation"), KErrArgument));
   1.131 +
   1.132 +	// eglCreateContext
   1.133 +	iContext = eglCreateContext(iDisplay, iUseConfig, EGL_NO_CONTEXT, NULL);
   1.134 +	TestL(iContext!=EGL_NO_CONTEXT, _L("eglCreateContext failed"));
   1.135 +
   1.136 +	// Make surface and context current on the display object
   1.137 +	ret = eglMakeCurrent(iDisplay, iSurface, iSurface, iContext);
   1.138 +	TestL(ret, _L("eglMakeCurrent failed"));
   1.139 +
   1.140 +	CheckVgErrorL(_L("VG_Problems creating second surface"));
   1.141 +	}
   1.142 +
   1.143 +
   1.144 +CVgAnimation::~CVgAnimation()
   1.145 +	{
   1.146 +	}
   1.147 +
   1.148 +void CVgAnimation::CheckVgErrorL(const TDesC& aMessage)
   1.149 +	{
   1.150 +	VGErrorCode err=vgGetError();
   1.151 +	if (err != VG_NO_ERROR)
   1.152 +		{
   1.153 +		RDebug::Print(_L("Error:0x%x - %S"),err,&aMessage);
   1.154 +		User::Leave(KErrUnknown);
   1.155 +		}
   1.156 +	}