Update contrib.
1 // Copyright (c) 2000-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.
16 #include <graphicsaccelerator.h>
21 Constructor with a software or hardware bitmap.
22 Its type is initialised to EFbsBitmap or EHardwareBitmap accordingly.
24 @param aBitmap The bitmap which the object will access.
26 EXPORT_C TAcceleratedBitmapSpec::TAcceleratedBitmapSpec(CFbsBitmap* aBitmap)
28 RHardwareBitmap hwb(aBitmap->HardwareBitmapHandle());
31 ::new (this) TAcceleratedBitmapSpec(hwb);
35 iHandle = REINTERPRET_CAST(TInt,aBitmap);
37 iLockStatus = EBitmapNeedsLocking;
44 Constructor with a hardware bitmap. Its type is initialised to EHardwareBitmap.
46 @param aBitmap The bitmap which the object will access.
48 EXPORT_C TAcceleratedBitmapSpec::TAcceleratedBitmapSpec(RHardwareBitmap aBitmap)
50 iType = EHardwareBitmap;
51 iHandle = aBitmap.iHandle;
52 iLockStatus = EBitmapIsStatic;
58 Fills a TAcceleratedBitmapInfo structure with data for the bitmap.
60 This data is only valid for the duration of any processing between a Lock()/Unlock()
63 For compressed bitmaps the line pitch has no meaning so it is set to the negation
64 of the compression type as defined by TBitmapfileCompression.
66 @param aInfo On return, holds the information needed to directly access the
68 @return KErrNone if sucessful, otherwise one of the system error codes, including
69 KErrUnknown if the object's type is ENoBitmap.
71 EXPORT_C TInt TAcceleratedBitmapSpec::GetInfo(TAcceleratedBitmapInfo& aInfo) const
77 CFbsBitmap* bmp = REINTERPRET_CAST(CFbsBitmap*,iHandle);
78 aInfo.iDisplayMode = bmp->DisplayMode();
79 aInfo.iAddress = REINTERPRET_CAST(TUint8*,bmp->DataAddress());
80 aInfo.iSize = bmp->SizeInPixels();
81 SEpocBitmapHeader header = bmp->Header();
82 if (header.iCompression != ENoBitmapCompression)
84 aInfo.iLinePitch = -header.iCompression;
88 aInfo.iLinePitch = bmp->ScanLineLength(aInfo.iSize.iWidth,aInfo.iDisplayMode);
90 TUid extendedType = bmp->ExtendedBitmapType();
91 if (extendedType != KNullUid)
93 aInfo.iPixelShift = extendedType.iUid;
94 aInfo.iDataSize = bmp->DataSize();
98 aInfo.iPhysicalAddress = NULL;
99 switch(aInfo.iDisplayMode)
102 aInfo.iPixelShift = -1;
105 aInfo.iPixelShift = 0;
108 aInfo.iPixelShift = 1;
112 aInfo.iPixelShift = 2;
116 aInfo.iPixelShift = 3;
120 aInfo.iPixelShift = 4;
127 aInfo.iPixelShift = 5;
130 aInfo.iPixelShift = -1;
137 case EHardwareBitmap:
138 return RHardwareBitmap(iHandle).GetInfo(aInfo);
142 Mem::FillZ(&aInfo,sizeof(aInfo));
147 /** Locks the bitmap, if required.
148 @param aCount Reference to a bitmap lock count object for nesting
149 (only the first instance does the locking). */
150 EXPORT_C void TAcceleratedBitmapSpec::DoLock(TBitmapLockCount& aCount)
156 REINTERPRET_CAST(CFbsBitmap*,iHandle)->BeginDataAccess();
160 case EHardwareBitmap:
162 // Never needs locking
167 /** Locks the bitmap, if required, setting the accelerated
168 bitmap information address.
169 @param aCount Reference to a bitmap lock count object for nesting
170 (only the first instance does the locking).
171 @param aInfo Information structure to set the address in. */
172 EXPORT_C void TAcceleratedBitmapSpec::DoLock(TBitmapLockCount& aCount,TAcceleratedBitmapInfo& aInfo)
179 REINTERPRET_CAST(CFbsBitmap*,iHandle)->BeginDataAccess();
181 CFbsBitmap* bmp = REINTERPRET_CAST(CFbsBitmap*,iHandle);
182 aInfo.iAddress = REINTERPRET_CAST(TUint8*,bmp->DataAddress());
187 case EHardwareBitmap:
189 // Never needs locking
194 /** Unlocks the bitmap, if required.
195 @param aCount Reference to a bitmap lock count object for nesting
196 (only the last instance does the unlocking). */
197 EXPORT_C void TAcceleratedBitmapSpec::DoUnlock(TBitmapLockCount& aCount)
203 REINTERPRET_CAST(CFbsBitmap*,iHandle)->EndDataAccess();
207 case EHardwareBitmap:
209 // Never needs unlocking