equal
deleted
inserted
replaced
1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
47 CDrawXxxBppBitmap::iScanLineWords = iHelper.BytesPerScanline() / 4; |
47 CDrawXxxBppBitmap::iScanLineWords = iHelper.BytesPerScanline() / 4; |
48 if (CDrawXxxBppBitmap::iScanLineWords==0) |
48 if (CDrawXxxBppBitmap::iScanLineWords==0) |
49 { //Note: This will cause WServ startup to fail. WServ only accepts KErrNotSupported |
49 { //Note: This will cause WServ startup to fail. WServ only accepts KErrNotSupported |
50 return KErrHardwareNotAvailable; |
50 return KErrHardwareNotAvailable; |
51 } |
51 } |
52 TInt ret = CDrawXxxBppBitmap::Construct(aSize, iHelper.BytesPerScanline()); |
52 TInt ret = CDrawXxxBppBitmap::Construct(aSize, CDrawXxxBppBitmap::iScanLineWords << 2); |
53 if (ret == KErrNone) |
53 if (ret == KErrNone) |
54 { |
54 { |
55 CDrawXxxBppBitmap::iBits = (TUint32*)iHelper.AddressFirstPixel(); |
55 CDrawXxxBppBitmap::iBits = (TUint32*)iHelper.AddressFirstPixel(); |
56 if (CDrawXxxBppBitmap::iBits==NULL) |
56 if (CDrawXxxBppBitmap::iBits==NULL) |
57 { //Note: This will cause WServ startup to fail. WServ only accepts KErrNotSupported |
57 { //Note: This will cause WServ startup to fail. WServ only accepts KErrNotSupported |
96 iHelper.Update(); |
96 iHelper.Update(); |
97 } |
97 } |
98 |
98 |
99 template <class T> void CGenericScreenDevice<T>::Update(const TRegion& aRegion) |
99 template <class T> void CGenericScreenDevice<T>::Update(const TRegion& aRegion) |
100 { |
100 { |
101 if(!aRegion.IsEmpty() && !aRegion.CheckError()) |
101 iHelper.Update(aRegion); |
102 { |
|
103 if (aRegion.Count()>KMaxUpdateRegionRectangles) |
|
104 { |
|
105 UpdateRegion(aRegion.BoundingRect()); |
|
106 } |
|
107 else |
|
108 { |
|
109 TInt rcCnt = aRegion.Count(); |
|
110 for (TInt ii=0; ii < rcCnt; ++ii) |
|
111 { |
|
112 UpdateRegion(aRegion[ii]); //Applies deorientate (offset, scale, rotate) |
|
113 } |
|
114 } |
|
115 } |
|
116 Update(); |
|
117 } |
102 } |
118 |
103 |
119 template <class T> void CGenericScreenDevice<T>::UpdateRegion(const TRect& aRect) |
104 template <class T> void CGenericScreenDevice<T>::UpdateRegion(const TRect& aRect) |
120 { |
105 { |
121 const TRect rect = CDrawXxxBppBitmap::DeOrientate(aRect);//rect - physical coordinates |
106 iHelper.UpdateRegion(aRect); |
122 |
107 } |
123 iHelper.UpdateRegion(rect); |
|
124 } |
|
125 |
108 |
126 template <class T> TInt CGenericScreenDevice<T>::GetInterface(TInt aInterfaceId, TAny*& aInterface) |
109 template <class T> TInt CGenericScreenDevice<T>::GetInterface(TInt aInterfaceId, TAny*& aInterface) |
127 { |
110 { |
128 if(aInterfaceId == KSurfaceInterfaceID) |
111 if(aInterfaceId == KSurfaceInterfaceID) |
129 { |
112 { |
190 { |
173 { |
191 return EFalse; |
174 return EFalse; |
192 } |
175 } |
193 |
176 |
194 // Need to update size, scan line size, etc. |
177 // Need to update size, scan line size, etc. |
|
178 CGenericScreenDevice::SetSize(newSize); |
|
179 |
|
180 // Setting iScanLineWords MUST occur after the call to SetSize because SetSize itself |
|
181 // sets iScanLineBytes to support offscreen bitmaps and may do so incorrectly for hardware devices |
|
182 // as it just uses the width, whereas BytesPerScanline takes into account any extra bytes needed |
|
183 // as defined by the hardware. |
195 CGenericScreenDevice::iScanLineWords = CGenericScreenDevice::iHelper.BytesPerScanline() / 4; //presumption here that BPS is always mod4. |
184 CGenericScreenDevice::iScanLineWords = CGenericScreenDevice::iHelper.BytesPerScanline() / 4; //presumption here that BPS is always mod4. |
196 CGenericScreenDevice::iBits = (TUint32*)CGenericScreenDevice::iHelper.AddressFirstPixel(); |
185 CGenericScreenDevice::iBits = (TUint32*)CGenericScreenDevice::iHelper.AddressFirstPixel(); |
197 __ASSERT_ALWAYS(CGenericScreenDevice::iScanLineWords && CGenericScreenDevice::iBits,Panic(EScreenDriverPanicInvalidHalValue)); |
186 __ASSERT_ALWAYS(CGenericScreenDevice::iScanLineWords && CGenericScreenDevice::iBits,Panic(EScreenDriverPanicInvalidHalValue)); |
198 CGenericScreenDevice::SetSize(newSize); |
|
199 |
187 |
200 return ETrue; |
188 return ETrue; |
201 } |
189 } |
202 |
190 |
203 |
191 |
231 { |
219 { |
232 return EFalse; |
220 return EFalse; |
233 } |
221 } |
234 |
222 |
235 // Need to update size, scan line size, etc. |
223 // Need to update size, scan line size, etc. |
|
224 CGenericScreenDevice::SetSize(newSize); |
|
225 |
|
226 // Setting iScanLineWords MUST occur after the call to SetSize because SetSize itself |
|
227 // sets iScanLineBytes to support offscreen bitmaps and may do so incorrectly for hardware devices |
|
228 // as it just uses the width, whereas BytesPerScanline takes into account any extra bytes needed |
|
229 // as defined by the hardware. |
236 CGenericScreenDevice::iScanLineWords = CGenericScreenDevice::iHelper.BytesPerScanline() / 4; //presumption here that BPS is always mod4. |
230 CGenericScreenDevice::iScanLineWords = CGenericScreenDevice::iHelper.BytesPerScanline() / 4; //presumption here that BPS is always mod4. |
237 CGenericScreenDevice::iBits = (TUint32*)CGenericScreenDevice::iHelper.AddressFirstPixel(); |
231 CGenericScreenDevice::iBits = (TUint32*)CGenericScreenDevice::iHelper.AddressFirstPixel(); |
238 __ASSERT_ALWAYS(CGenericScreenDevice::iScanLineWords && CGenericScreenDevice::iBits,Panic(EScreenDriverPanicInvalidHalValue)); |
232 __ASSERT_ALWAYS(CGenericScreenDevice::iScanLineWords && CGenericScreenDevice::iBits,Panic(EScreenDriverPanicInvalidHalValue)); |
239 CGenericScreenDevice::SetSize(newSize); |
|
240 |
233 |
241 return ETrue; |
234 return ETrue; |
242 } |
235 } |
243 |
236 |
244 |
237 |