graphicstest/uibench/s60/src/windows/tflowwindow.cpp
changeset 0 5d03bc08d59c
child 36 01a6848ebfd7
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code 
       
    20 */
       
    21 
       
    22 #include "tflowwindow.h"
       
    23 #include "surfaceutility.h"
       
    24 
       
    25 
       
    26 CTWindow* CTFlowWindow::NewL(RWsSession &aWs, const RWindowTreeNode &aParent, const TPoint& aStartingPoint, const TSize& aWindowSize)
       
    27     {
       
    28     CTFlowWindow * self = new (ELeave) CTFlowWindow(aStartingPoint, aWindowSize);
       
    29     CleanupStack::PushL(self);
       
    30     self->ConstructL(aWs, aParent);
       
    31     CleanupStack::Pop(self);
       
    32     return self;
       
    33     }
       
    34 
       
    35 CTFlowWindow::CTFlowWindow(const TPoint& aStartingPoint, const TSize& aWindowSize) : CTWindow(aStartingPoint, aWindowSize)
       
    36     {
       
    37     iImageInfo.iSizeInPixels = aWindowSize;
       
    38     iImageInfo.iPixelFormat = EUidPixelFormatXRGB_8888; //todo: is this format okay (EUidPixelFormatARGB_8888)?
       
    39     iImageInfo.iCpuAccess = ESgCpuAccessNone;
       
    40     iImageInfo.iUsage = ESgUsageOpenGlesTarget| ESgUsageDirectGdiSource | ESgUsageDirectGdiTarget;
       
    41     iImageInfo.iShareable = ETrue;
       
    42     iImageInfo.iScreenId = KSgScreenIdMain;
       
    43     }
       
    44 
       
    45 void CTFlowWindow::ConstructL(RWsSession &aWs, const RWindowTreeNode &aParent)
       
    46 	{
       
    47 	CTWindow::ConstructL(aWs, aParent);
       
    48 	
       
    49 	User::LeaveIfError(iImageCollection.Create(iImageInfo, 1)); // creates an image collection with 1 image
       
    50 	User::LeaveIfError(iImageCollection.OpenImage(0, iImage)); // opens a handle to the image
       
    51 	// sets the image collection as background surface for the window
       
    52 	User::LeaveIfError(SetBackgroundSurface(iImageCollection.SurfaceId()));
       
    53 	// Connect to surface update session
       
    54 	User::LeaveIfError(iUpdateSession.Connect());
       
    55 	}
       
    56 
       
    57 CTFlowWindow::~CTFlowWindow()
       
    58     {
       
    59     iUpdateSession.Close();
       
    60     iImage.Close();
       
    61     iImageCollection.Close();
       
    62     }
       
    63 
       
    64 /**
       
    65  * Scales a bitmap from file to a surface.
       
    66  * 
       
    67  * @param aUtility Performs the loading of the bitmap and scaling to the surface.
       
    68  * @param aFileName Location of the bitmap.
       
    69  */
       
    70 void CTFlowWindow::LoadL(CSurfaceUtility* aUtility, TPtrC aFileName)
       
    71 	{
       
    72 	aUtility->ScaleBitmapFromFileToSurfaceL(aFileName, iImageCollection.SurfaceId());
       
    73 	}
       
    74 
       
    75 void CTFlowWindow::RenderL()
       
    76     {
       
    77     CTWindow::RenderL();
       
    78     TRequestStatus status;
       
    79     iUpdateSession.NotifyWhenAvailable(status);
       
    80     User::LeaveIfError(iUpdateSession.SubmitUpdate(KSgScreenIdMain, 
       
    81             iImageCollection.SurfaceId(), 0, &DirtyRegion()));
       
    82     User::WaitForRequest(status);
       
    83     }