sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent sl@0: */ sl@0: sl@0: #include "t_pseudoappvganimation.h" sl@0: sl@0: //for the inner square sl@0: const TReal32 KTlx = 0; sl@0: const TReal32 KTly = 0; sl@0: const TReal32 KSzx = 60; sl@0: const TReal32 KSzy = 60; sl@0: sl@0: void CVgAnimation::DrawToEglL() sl@0: { sl@0: // clear background sl@0: VGfloat bgColor[] = {0.0, 0.0, 0.0, 0.0}; sl@0: vgSetfv(VG_CLEAR_COLOR, 4, bgColor); sl@0: vgClear(0, 0, iSurfaceSize.iWidth, iSurfaceSize.iHeight); sl@0: sl@0: //paint creation and setting. sl@0: vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER); sl@0: vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_BETTER); sl@0: sl@0: VGPaint fillPaint=vgCreatePaint(); sl@0: CheckVgErrorL(_L("vgCreatePaint failed")); sl@0: sl@0: //the fill paint sl@0: VGfloat fillColor[4]; sl@0: fillColor[0] = 0.0f/255.0f; //blue sl@0: fillColor[1] = 255.0f/255.0f; //red sl@0: fillColor[2] = 0.0f/255.0f; //green sl@0: fillColor[3] = 255.0f/255.0f; //alpha = required to be 1.0 sl@0: sl@0: vgSetParameteri(fillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR); sl@0: CheckVgErrorL(_L("fillPaint VG_PAINT_TYPE failed")); sl@0: vgSetParameterfv(fillPaint, VG_PAINT_COLOR, 4, fillColor); sl@0: CheckVgErrorL(_L("fillPaint VG_PAINT_COLOR failed")); sl@0: sl@0: VGPath bgPath; sl@0: bgPath= vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_S_32, 1.0f, 0.0f, 4, 4, (unsigned int)VG_PATH_CAPABILITY_ALL); sl@0: CheckVgErrorL(_L("vgCreatePath failed")); sl@0: sl@0: VGUErrorCode vguerr=vguEllipse(bgPath, KTlx, KTly, KSzx, KSzy); sl@0: TestL(vguerr==VGU_NO_ERROR, _L("vguRect failed")); sl@0: CheckVgErrorL(_L("vguRect failed")); sl@0: sl@0: vgSetPaint(fillPaint, VG_FILL_PATH); sl@0: CheckVgErrorL(_L("VG_FILL_PATH failed")); sl@0: sl@0: vgLoadIdentity(); sl@0: sl@0: vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); sl@0: CheckVgErrorL(_L("vgLoadIdentity failed")); sl@0: sl@0: vgTranslate(iX, iY); sl@0: sl@0: vgDrawPath(bgPath, VG_FILL_PATH); sl@0: CheckVgErrorL(_L("vgDrawPath failed")); sl@0: sl@0: vgDestroyPath(bgPath); sl@0: vgDestroyPaint(fillPaint); sl@0: sl@0: vgFinish(); sl@0: sl@0: TInt ret=eglSwapBuffers(iDisplay,iSurface); sl@0: TestL(ret,_L("eglSwapBuffers failed")); sl@0: } sl@0: sl@0: void CVgAnimation::DrawL(CTestSurfaceRasterizer* /*aSurfaceRasterizer*/, SurfaceDetails& /*aSurfDetails*/) sl@0: { sl@0: DrawToEglL(); sl@0: sl@0: if (iY >= iSurfaceSize.iHeight || iX >= iSurfaceSize.iWidth ) sl@0: { sl@0: iX=0; sl@0: iY=0; sl@0: } sl@0: else sl@0: { sl@0: iX+=iHorizontalRate; sl@0: iY+=iVerticalRate; sl@0: } sl@0: } sl@0: sl@0: CVgAnimation* CVgAnimation::NewL(RWindow* aWin, const TDisplayMode& aMode, const TSize& aSurfaceSize, sl@0: const TInt aHorizontalRate, sl@0: const TInt aVerticalRate) sl@0: { sl@0: RDebug::Print(_L("Creating CVgAnimation class\n")); sl@0: CVgAnimation* self = new (ELeave) CVgAnimation(aMode,aSurfaceSize,aHorizontalRate,aVerticalRate); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aWin); sl@0: CleanupStack::Pop(); // self; sl@0: return self; sl@0: } sl@0: sl@0: CVgAnimation::CVgAnimation(const TDisplayMode& aMode, const TSize& aSurfaceSize, const TInt aHorizontalRate, const TInt aVerticalRate) sl@0: : CEglBase(aMode,aSurfaceSize,aHorizontalRate,aVerticalRate) sl@0: { sl@0: } sl@0: sl@0: void CVgAnimation::ConstructL(RWindow* aWin) sl@0: { sl@0: BaseConstructL(aWin); sl@0: sl@0: // eglBindAPI sl@0: TInt ret = eglBindAPI(EGL_OPENVG_API); sl@0: TestL(ret, _L("eglBindAPI failed")); sl@0: sl@0: __ASSERT_DEBUG(iUseConfig>0, User::Panic(_L("CVgAnimation"), KErrArgument)); sl@0: sl@0: // eglCreateContext sl@0: iContext = eglCreateContext(iDisplay, iUseConfig, EGL_NO_CONTEXT, NULL); sl@0: TestL(iContext!=EGL_NO_CONTEXT, _L("eglCreateContext failed")); sl@0: sl@0: // Make surface and context current on the display object sl@0: ret = eglMakeCurrent(iDisplay, iSurface, iSurface, iContext); sl@0: TestL(ret, _L("eglMakeCurrent failed")); sl@0: sl@0: CheckVgErrorL(_L("VG_Problems creating second surface")); sl@0: } sl@0: sl@0: sl@0: CVgAnimation::~CVgAnimation() sl@0: { sl@0: } sl@0: sl@0: void CVgAnimation::CheckVgErrorL(const TDesC& aMessage) sl@0: { sl@0: VGErrorCode err=vgGetError(); sl@0: if (err != VG_NO_ERROR) sl@0: { sl@0: RDebug::Print(_L("Error:0x%x - %S"),err,&aMessage); sl@0: User::Leave(KErrUnknown); sl@0: } sl@0: }