1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicstest/uibench/s60/src/windows/tsmallwindowraster.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,98 @@
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 +
1.26 +#include "tsmallwindowraster.h"
1.27 +
1.28 +
1.29 +_LIT(KBitmapPattern, "*.mbm");
1.30 +
1.31 +
1.32 +CTSmallWindowRaster::CTSmallWindowRaster(const TPoint& aStartingPoint, const TSize& aWindowSize) :
1.33 + CTWindow(aStartingPoint, aWindowSize)
1.34 + {
1.35 + // empty
1.36 + }
1.37 +
1.38 +CTSmallWindowRaster::~CTSmallWindowRaster()
1.39 + {
1.40 + if (iGc)
1.41 + {
1.42 + iGc->Deactivate();
1.43 + delete iGc;
1.44 + }
1.45 + delete iSourceBitmap;
1.46 + delete iScreenDev;
1.47 + }
1.48 +
1.49 +CTWindow* CTSmallWindowRaster::NewL(RWsSession &aWs,
1.50 + const RWindowTreeNode &aParent,
1.51 + const TPoint& aStartingPoint,
1.52 + const TSize& aWindowSize)
1.53 + {
1.54 + CTSmallWindowRaster* self = new (ELeave) CTSmallWindowRaster(aStartingPoint, aWindowSize);
1.55 + CleanupStack::PushL(self);
1.56 + self->ConstructL(aWs, aParent);
1.57 + CleanupStack::Pop(self);
1.58 + return self;
1.59 + }
1.60 +
1.61 +void CTSmallWindowRaster::ConstructL(RWsSession &aWs, const RWindowTreeNode &aParent)
1.62 + {
1.63 + CTWindow::ConstructL(aWs, aParent);
1.64 + iScreenDev = new (ELeave) CWsScreenDevice(aWs);
1.65 + User::LeaveIfError(iScreenDev->Construct());
1.66 + iGc = new (ELeave)CWindowGc(iScreenDev);
1.67 + User::LeaveIfError(iGc->Construct());
1.68 + iGc->Activate(iWindow);
1.69 + }
1.70 +
1.71 +void CTSmallWindowRaster::LoadL(CSurfaceUtility* /*aUtility*/, TPtrC aFileName)
1.72 + {
1.73 + iLoaded = ETrue;
1.74 + if (aFileName.Match(KBitmapPattern()) != KErrNotFound) // it's a Bitmap
1.75 + {
1.76 + iSourceBitmap = new(ELeave) CFbsBitmap();
1.77 + User::LeaveIfError(iSourceBitmap->Load(aFileName, 0));
1.78 + }
1.79 + else
1.80 + {
1.81 + iSourceBitmap = CreateBitmapFromFileL(aFileName);
1.82 + }
1.83 + iSourceRect = iSourceBitmap->SizeInPixels();
1.84 + iDestRect = TRect(Size());
1.85 + }
1.86 +
1.87 +void CTSmallWindowRaster::DrawBitmap(TRect& aSourceRect)
1.88 + {
1.89 + iWindow.BeginRedraw();
1.90 + iGc->DrawBitmap(iDestRect, iSourceBitmap, aSourceRect);
1.91 + iWindow.EndRedraw();
1.92 + }
1.93 +
1.94 +void CTSmallWindowRaster::RenderL()
1.95 + {
1.96 + CTWindow::RenderL();
1.97 + if (iLoaded)
1.98 + {
1.99 + DrawBitmap(iSourceRect);
1.100 + }
1.101 + }