First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 @internalComponent - Internal Symbian test code
22 #include "tflowwindow.h"
23 #include "surfaceutility.h"
26 CTWindow* CTFlowWindow::NewL(RWsSession &aWs, const RWindowTreeNode &aParent, const TPoint& aStartingPoint, const TSize& aWindowSize)
28 CTFlowWindow * self = new (ELeave) CTFlowWindow(aStartingPoint, aWindowSize);
29 CleanupStack::PushL(self);
30 self->ConstructL(aWs, aParent);
31 CleanupStack::Pop(self);
35 CTFlowWindow::CTFlowWindow(const TPoint& aStartingPoint, const TSize& aWindowSize) : CTWindow(aStartingPoint, aWindowSize)
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;
45 void CTFlowWindow::ConstructL(RWsSession &aWs, const RWindowTreeNode &aParent)
47 CTWindow::ConstructL(aWs, aParent);
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());
57 CTFlowWindow::~CTFlowWindow()
59 iUpdateSession.Close();
61 iImageCollection.Close();
65 * Scales a bitmap from file to a surface.
67 * @param aUtility Performs the loading of the bitmap and scaling to the surface.
68 * @param aFileName Location of the bitmap.
70 void CTFlowWindow::LoadL(CSurfaceUtility* aUtility, TPtrC aFileName)
72 aUtility->ScaleBitmapFromFileToSurfaceL(aFileName, iImageCollection.SurfaceId());
75 void CTFlowWindow::RenderL()
78 TRequestStatus status;
79 iUpdateSession.NotifyWhenAvailable(status);
80 User::LeaveIfError(iUpdateSession.SubmitUpdate(KAllScreens,
81 iImageCollection.SurfaceId(), 0, &DirtyRegion()));
82 User::WaitForRequest(status);