os/graphics/graphicstest/uibench/s60/src/windows/tflowwindow.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicstest/uibench/s60/src/windows/tflowwindow.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,83 @@
     1.4 +// Copyright (c) 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 - Internal Symbian test code 
    1.23 +*/
    1.24 +
    1.25 +#include "tflowwindow.h"
    1.26 +#include "surfaceutility.h"
    1.27 +
    1.28 +
    1.29 +CTWindow* CTFlowWindow::NewL(RWsSession &aWs, const RWindowTreeNode &aParent, const TPoint& aStartingPoint, const TSize& aWindowSize)
    1.30 +    {
    1.31 +    CTFlowWindow * self = new (ELeave) CTFlowWindow(aStartingPoint, aWindowSize);
    1.32 +    CleanupStack::PushL(self);
    1.33 +    self->ConstructL(aWs, aParent);
    1.34 +    CleanupStack::Pop(self);
    1.35 +    return self;
    1.36 +    }
    1.37 +
    1.38 +CTFlowWindow::CTFlowWindow(const TPoint& aStartingPoint, const TSize& aWindowSize) : CTWindow(aStartingPoint, aWindowSize)
    1.39 +    {
    1.40 +    iImageInfo.iSizeInPixels = aWindowSize;
    1.41 +    iImageInfo.iPixelFormat = EUidPixelFormatXRGB_8888; //todo: is this format okay (EUidPixelFormatARGB_8888)?
    1.42 +    iImageInfo.iCpuAccess = ESgCpuAccessNone;
    1.43 +    iImageInfo.iUsage = ESgUsageOpenGlesTarget| ESgUsageDirectGdiSource | ESgUsageDirectGdiTarget;
    1.44 +    iImageInfo.iShareable = ETrue;
    1.45 +    iImageInfo.iScreenId = KSgScreenIdMain;
    1.46 +    }
    1.47 +
    1.48 +void CTFlowWindow::ConstructL(RWsSession &aWs, const RWindowTreeNode &aParent)
    1.49 +	{
    1.50 +	CTWindow::ConstructL(aWs, aParent);
    1.51 +	
    1.52 +	User::LeaveIfError(iImageCollection.Create(iImageInfo, 1)); // creates an image collection with 1 image
    1.53 +	User::LeaveIfError(iImageCollection.OpenImage(0, iImage)); // opens a handle to the image
    1.54 +	// sets the image collection as background surface for the window
    1.55 +	User::LeaveIfError(SetBackgroundSurface(iImageCollection.SurfaceId()));
    1.56 +	// Connect to surface update session
    1.57 +	User::LeaveIfError(iUpdateSession.Connect());
    1.58 +	}
    1.59 +
    1.60 +CTFlowWindow::~CTFlowWindow()
    1.61 +    {
    1.62 +    iUpdateSession.Close();
    1.63 +    iImage.Close();
    1.64 +    iImageCollection.Close();
    1.65 +    }
    1.66 +
    1.67 +/**
    1.68 + * Scales a bitmap from file to a surface.
    1.69 + * 
    1.70 + * @param aUtility Performs the loading of the bitmap and scaling to the surface.
    1.71 + * @param aFileName Location of the bitmap.
    1.72 + */
    1.73 +void CTFlowWindow::LoadL(CSurfaceUtility* aUtility, TPtrC aFileName)
    1.74 +	{
    1.75 +	aUtility->ScaleBitmapFromFileToSurfaceL(aFileName, iImageCollection.SurfaceId());
    1.76 +	}
    1.77 +
    1.78 +void CTFlowWindow::RenderL()
    1.79 +    {
    1.80 +    CTWindow::RenderL();
    1.81 +    TRequestStatus status;
    1.82 +    iUpdateSession.NotifyWhenAvailable(status);
    1.83 +    User::LeaveIfError(iUpdateSession.SubmitUpdate(KAllScreens, 
    1.84 +            iImageCollection.SurfaceId(), 0, &DirtyRegion()));
    1.85 +    User::WaitForRequest(status);
    1.86 +    }