First public contribution.
1 // Copyright (c) 2001-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"
20 #pragma warning( disable : 4201 )
21 #define WIN32_LEAN_AND_MEAN
25 #pragma warning( default : 4201 )
30 /** Fills a structure with data which describes the basic details of this bitmap.
32 @param aInfo Bitmap information structure to fill with the details of this bitmap.
33 @return KErrNone if successful, KErrBadHandle if a value has not been assigned to iHandle. */
34 EXPORT_C TInt RHardwareBitmap::GetInfo(TAcceleratedBitmapInfo& aInfo) const
37 return(KErrBadHandle);
39 // -1 or less refers to the screen. It is the (screen number + 1) actually with "-" sign.
42 RWindows* window = ::WindowHandler(-iHandle - 1);
43 aInfo.iDisplayMode = window->iDisplayMode;
44 aInfo.iAddress = (TUint8*)(window->EpocBitmapBits());
45 aInfo.iSize = window->iEpocBitmapSize;
46 aInfo.iLinePitch = window->iEpocBitmapLinePitch;
47 aInfo.iPhysicalAddress = 0;
48 switch(aInfo.iDisplayMode)
51 aInfo.iPixelShift = -1;
54 aInfo.iPixelShift = 0;
57 aInfo.iPixelShift = 1;
61 aInfo.iPixelShift = 2;
65 aInfo.iPixelShift = 3;
69 aInfo.iPixelShift = 4;
74 aInfo.iPixelShift = 5;
79 aInfo = *(TAcceleratedBitmapInfo*)iHandle; // iHandle is really a pointer to a TAcceleratedBitmapInfo
85 This method sets the value of iHandle data member.
86 When the iHandle's value is positive - the it is the bitmap address in the memory.
87 When the iHandle's value is negative - it is a screen number reference:
88 "-1" - screen 0, "-2" - screen 1, "-3" - screen 2, ...
89 All that means: negative iHandle values describe the RHardwareBitmap object as a screen
90 bitmap, the screen number can be calculated from iHandle's value.
91 Positive iHandle values describe RHardwareBitmap object as an in-memory bitmap.
92 By default iHandle is initialized with 0, which means - invalid handle and uninitialized
93 RHardwareBitmap object.
94 @param aScreenNo Screen number.
97 EXPORT_C TInt RHardwareBitmap::SetAsScreenReference(TInt aScreenNo)
103 EXPORT_C TInt RHardwareBitmap::Create(TDisplayMode aDisplayMode, TSize aSize, TUid /*aCreatorUid*/)
105 // Make line pitch different from normal bitmaps, useful for testing purposes.
106 TInt hwWidth = ((aSize.iWidth + 15) / 16) * 16;
118 linePitch = hwWidth * 2;
121 linePitch = (((hwWidth * 3) + 11) / 12) * 12; // Multiples of 12 bytes!
125 linePitch = hwWidth * 4;
128 return(KErrNotSupported);
131 TInt memSize = sizeof(TAcceleratedBitmapInfo)+linePitch*aSize.iHeight;
133 TAcceleratedBitmapInfo* bitmap = (TAcceleratedBitmapInfo*)GlobalAllocPtr(GMEM_FIXED,memSize);
136 return(KErrNoMemory);
138 bitmap->iDisplayMode = aDisplayMode;
139 bitmap->iAddress = (TUint8*)(bitmap+1);
140 bitmap->iSize = aSize;
141 bitmap->iLinePitch = linePitch;
145 bitmap->iPixelShift = -1;
148 bitmap->iPixelShift = 0;
151 bitmap->iPixelShift = 1;
155 bitmap->iPixelShift = 2;
159 bitmap->iPixelShift = 3;
163 bitmap->iPixelShift = 4;
168 bitmap->iPixelShift = 5;
171 bitmap->iPhysicalAddress = 0;
173 iHandle = (TInt)bitmap;
178 EXPORT_C void RHardwareBitmap::Destroy()
180 GlobalFreePtr((void*)iHandle);