annotate src/video/symbian/EKA2/dsa_new.cpp @ 4255:5a203e2b0162 SDL-1.2

Fixed bug #716 Armin Burgmeier 2009-03-15 04:35:45 PDT When I hold a mouse button down on another (non-SDL) window, then move the mouse over an SDL window and releasing the mouse button there, then the application does not receive an SDL_ACTIVEEVENT with state SDL_APPMOUSEFOCUS and gain 1. Furthermore, SDL_GetAppState() reports the application not having mouse focus until moving the mouse out of the window and back in again.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 27 Sep 2009 23:22:57 +0000
parents e85e65aec22f
children
rev   line source
3975
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1 #include "dsa.h"
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
2 #include "sdlepocapi.h"
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
3 #include <cdsb.h>
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
4
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
5
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
6 LOCAL_C TInt BytesPerPixel(TDisplayMode aMode)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
7 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
8 return ((TDisplayModeUtils::NumDisplayModeBitsPerPixel(aMode) - 1) >> 3) + 1;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
9 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
10
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
11
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
12 NONSHARABLE_CLASS(TDsa)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
13 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
14 public:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
15 inline TDsa(const CDsa& aDsa);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
16 inline TBool IsFlip() const;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
17 inline TBool IsTurn() const;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
18 inline const TSize& SwSize() const;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
19 inline void Copy(TUint32* aTarget, const TUint8* aSrc, TInt aBytes, TInt aHeight) const;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
20 private:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
21 const CDsa& iDsa;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
22 };
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
23
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
24
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
25 inline TDsa::TDsa(const CDsa& aDsa) : iDsa(aDsa)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
26 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
27 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
28
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
29 inline TBool TDsa::IsTurn() const
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
30 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
31 return iDsa.iStateFlags & CDsa::EOrientation90;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
32 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
33
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
34 inline TBool TDsa::IsFlip() const
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
35 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
36 return iDsa.iStateFlags & CDsa::EOrientation180;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
37 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
38
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
39 inline const TSize& TDsa::SwSize() const
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
40 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
41 return iDsa.SwSize();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
42 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
43
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
44 inline void TDsa::Copy(TUint32* aTarget, const TUint8* aSrc, TInt aBytes, TInt aHeight) const
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
45 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
46 iDsa.iCopyFunction(iDsa, aTarget, aSrc, aBytes, aHeight);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
47 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
48
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
49 template<class T, class S>
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
50 void ClipCopy(const TDsa& iDsa, TUint8* aTarget,
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
51 const TUint8* aSource,
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
52 const TRect& aUpdateRect,
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
53 const TRect& aSourceRect)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
54 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
55 const S* source = reinterpret_cast<const S*>(aSource);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
56 const TInt lineWidth = aSourceRect.Width();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
57
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
58 source += (aUpdateRect.iTl.iY * lineWidth);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
59 const TInt sourceStartOffset = aUpdateRect.iTl.iX;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
60 source += sourceStartOffset;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
61
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
62 T* targetPtr = reinterpret_cast<T*>(aTarget);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
63
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
64 const TInt scanLineWidth = iDsa.SwSize().iWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
65
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
66 targetPtr += (aSourceRect.iTl.iY + aUpdateRect.iTl.iY ) * scanLineWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
67 const TInt targetStartOffset = (aUpdateRect.iTl.iX + aSourceRect.iTl.iX);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
68
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
69 targetPtr += targetStartOffset;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
70
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
71
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
72 const TInt height = aUpdateRect.Height();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
73
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
74 const TInt lineMove = iDsa.IsTurn() ? 1 : lineWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
75 const TInt copyLen = aUpdateRect.Width();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
76
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
77
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
78 if(iDsa.IsFlip())
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
79 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
80
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
81 targetPtr += scanLineWidth * (height - 1);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
82
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
83 for(TInt i = 0; i < height; i++) //source is always smaller
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
84 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
85 iDsa.Copy(reinterpret_cast<TUint32*>(targetPtr), reinterpret_cast<const TUint8*>(source), copyLen, height);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
86 source += lineMove;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
87 targetPtr -= scanLineWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
88 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
89 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
90 else
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
91 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
92
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
93
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
94 for(TInt i = 0; i < height; i++) //source is always smaller
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
95 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
96 iDsa.Copy(reinterpret_cast<TUint32*>(targetPtr), reinterpret_cast<const TUint8*>(source), copyLen, height);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
97 source += lineMove;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
98 targetPtr += scanLineWidth; // >> 2;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
99 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
100 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
101
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
102 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
103
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
104
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
105
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
106 NONSHARABLE_CLASS(CDsaA) : public CDsa
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
107 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
108 public:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
109 CDsaA(RWsSession& aSession);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
110 private:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
111 ~CDsaA();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
112 TUint8* LockSurface();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
113 void UnlockHWSurfaceRequestComplete();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
114 void UnlockHwSurface();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
115 void CreateSurfaceL();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
116 void Wipe(TInt aLength);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
117 void Free();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
118 void Update(CFbsBitmap& aBmp);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
119 void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
120 TInt ExternalUpdate();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
121 // void ExternalUpdate();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
122 protected:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
123 CFbsBitmap* iBmp;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
124 CFbsBitmap* iCopyBmp;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
125 };
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
126
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
127
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
128 CDsaA::CDsaA(RWsSession& aSession) : CDsa(aSession)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
129 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
130 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
131
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
132
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
133 void CDsaA::Free()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
134 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
135 delete iBmp;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
136 iBmp = NULL;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
137 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
138
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
139 CDsaA::~CDsaA()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
140 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
141 __ASSERT_DEBUG(iBmp == NULL, PANIC(KErrNotReady));
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
142 delete iCopyBmp;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
143 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
144
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
145 TUint8* CDsaA::LockSurface()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
146 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
147 iBmp->LockHeap();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
148 return reinterpret_cast<TUint8*>(iBmp->DataAddress());
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
149 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
150
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
151 void CDsaA::UnlockHWSurfaceRequestComplete()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
152 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
153 PANIC(KErrNotSupported);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
154 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
155
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
156 void CDsaA::UnlockHwSurface()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
157 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
158 iBmp->UnlockHeap();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
159 SetUpdating(EFalse);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
160 Update(*iBmp);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
161 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
162
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
163 void CDsaA::Update(CFbsBitmap& aBmp)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
164 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
165 if(!Blitter(aBmp))
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
166 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
167 if(SwSize() == HwRect().Size())
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
168 Dsa().Gc()->BitBlt(HwRect().iTl, &aBmp);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
169 else
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
170 Dsa().Gc()->DrawBitmap(HwRect(), &aBmp);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
171 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
172 DrawOverlays();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
173 Dsa().ScreenDevice()->Update();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
174 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
175 void CDsaA::CreateSurfaceL()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
176 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
177 delete iBmp;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
178 iBmp = NULL;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
179 iBmp = new (ELeave) CFbsBitmap();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
180 User::LeaveIfError(iBmp->Create(SwSize(), DisplayMode()));
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
181 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
182
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
183 void CDsaA::Wipe(TInt aLength) //dont call in drawing
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
184 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
185 iBmp->LockHeap();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
186 Mem::FillZ(iBmp->DataAddress(), aLength);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
187 iBmp->UnlockHeap();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
188 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
189
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
190
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
191
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
192 TInt CDsaA::ExternalUpdate()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
193 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
194 if(iCopyBmp->Handle() == 0)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
195 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
196 const TInt err = iCopyBmp->Duplicate(iBmp->Handle());
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
197 if(err != KErrNone)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
198 return err;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
199 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
200 Update(*iCopyBmp);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
201 return KErrNone;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
202 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
203
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
204 void CDsaA::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
205 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
206 iCopyBmp = new (ELeave) CFbsBitmap();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
207 CDsa::ConstructL(aWindow, aDevice);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
208 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
209
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
210
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
211 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
212
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
213 NONSHARABLE_CLASS(MDsbObs)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
214 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
215 public:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
216 virtual void SurfaceReady() = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
217 virtual CDirectScreenBitmap& Dsb() = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
218 };
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
219
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
220 NONSHARABLE_CLASS(CDsbSurface) : public CActive
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
221 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
222 public:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
223 CDsbSurface(MDsbObs& aDsb);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
224 TUint8* Address();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
225 void Complete();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
226 ~CDsbSurface();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
227 private:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
228 void RunL();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
229 void DoCancel();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
230 private:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
231 MDsbObs& iDsb;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
232 TUint8* iAddress;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
233 };
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
234
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
235 CDsbSurface::CDsbSurface(MDsbObs& aDsb) : CActive(CActive::EPriorityHigh) , iDsb(aDsb)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
236 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
237 CActiveScheduler::Add(this);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
238 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
239
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
240 CDsbSurface::~CDsbSurface()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
241 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
242 Cancel();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
243 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
244
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
245 void CDsbSurface::Complete()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
246 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
247 if(iAddress != NULL && !IsActive())
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
248 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
249 iAddress = NULL;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
250 SetActive();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
251 iDsb.Dsb().EndUpdate(iStatus);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
252 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
253 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
254
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
255 TUint8* CDsbSurface::Address()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
256 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
257 if(iAddress == NULL && !IsActive())
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
258 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
259 TAcceleratedBitmapInfo info;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
260 if(KErrNone == iDsb.Dsb().BeginUpdate(info))
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
261 iAddress = info.iAddress;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
262 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
263 return iAddress;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
264 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
265
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
266 void CDsbSurface::RunL()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
267 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
268 iDsb.SurfaceReady();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
269 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
270
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
271 void CDsbSurface::DoCancel()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
272 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
273 //empty
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
274 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
275
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
276 NONSHARABLE_CLASS(CDsaB) : public CDsa, public MDsbObs
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
277 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
278 public:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
279 CDsaB(RWsSession& aSession, TInt aFlags);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
280 private:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
281 ~CDsaB();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
282 TUint8* LockSurface();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
283 void UnlockHWSurfaceRequestComplete();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
284 void UnlockHwSurface();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
285 void CreateSurfaceL();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
286 void Wipe(TInt aLength);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
287 void RecreateL();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
288 void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
289 CDirectScreenBitmap& Dsb();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
290 void SurfaceReady();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
291 TInt ExternalUpdate();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
292 private:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
293 CDsbSurface* iSurface1;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
294 CDsbSurface* iSurface2;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
295 CDirectScreenBitmap* iDsb;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
296 TInt iType;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
297 };
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
298
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
299 CDsaB::CDsaB(RWsSession& aSession, TInt aFlags) : CDsa(aSession), iType(aFlags)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
300 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
301 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
302
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
303
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
304
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
305 void CDsaB::UnlockHWSurfaceRequestComplete()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
306 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
307 iSurface1->Complete();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
308 if(iSurface2 != NULL)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
309 iSurface2->Complete();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
310 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
311
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
312 void CDsaB::CreateSurfaceL()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
313 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
314 __ASSERT_ALWAYS(SwSize() == HwRect().Size(), PANIC(KErrNotSupported));
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
315 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
316
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
317 void CDsaB::Wipe(TInt aLength) //dont call in drawing
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
318 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
319 TUint8* addr = LockSurface();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
320 if(addr != NULL)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
321 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
322 Mem::FillZ(addr, aLength);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
323 UnlockHwSurface();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
324 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
325 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
326
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
327
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
328 void CDsaB::UnlockHwSurface()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
329 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
330 EpocSdlEnv::Request(CDsa::ERequestUpdate);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
331 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
332
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
333 TUint8* CDsaB::LockSurface()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
334 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
335 TUint8* addr = iSurface1->Address();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
336 if(addr == NULL && iSurface2 != NULL)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
337 addr = iSurface2->Address();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
338 SetUpdating(addr == NULL);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
339 return addr;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
340 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
341
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
342 void CDsaB::SurfaceReady()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
343 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
344 SetUpdating(EFalse);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
345 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
346
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
347 CDirectScreenBitmap& CDsaB::Dsb()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
348 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
349 return *iDsb;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
350 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
351
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
352 void CDsaB::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
353 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
354 if(iDsb == NULL)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
355 iDsb = CDirectScreenBitmap::NewL();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
356 CDsa::ConstructL(aWindow, aDevice);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
357 if(iSurface1 == NULL)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
358 iSurface1 = new (ELeave) CDsbSurface(*this);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
359 if(iSurface2 == NULL && iType & CDirectScreenBitmap::EDoubleBuffer)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
360 iSurface2 = new (ELeave) CDsbSurface(*this);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
361 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
362
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
363 CDsaB::~CDsaB()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
364 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
365 delete iSurface1;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
366 delete iSurface2;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
367 delete iDsb;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
368 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
369
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
370 void CDsaB::RecreateL()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
371 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
372 iDsb->Close();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
373 iDsb->Create(HwRect(), CDirectScreenBitmap::TSettingsFlags(iType));
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
374 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
375
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
376 TInt CDsaB::ExternalUpdate()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
377 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
378 if(LockSurface())
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
379 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
380 UnlockHWSurfaceRequestComplete();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
381 return KErrNone;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
382 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
383 return KErrNotReady;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
384 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
385
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
386
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
387 /////////////////////////////////////////////////////////////////////////////////////////////////////
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
388
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
389
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
390 CDsa* CDsa::CreateL(RWsSession& aSession)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
391 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
392 if(EpocSdlEnv::Flags(CSDL::EDrawModeDSB))
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
393 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
394 TInt flags = CDirectScreenBitmap::ENone;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
395 if(EpocSdlEnv::Flags(CSDL::EDrawModeDSBDoubleBuffer))
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
396 flags |= CDirectScreenBitmap::EDoubleBuffer;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
397 if(EpocSdlEnv::Flags(CSDL::EDrawModeDSBIncrentalUpdate))
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
398 flags |= CDirectScreenBitmap::EIncrementalUpdate;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
399 return new (ELeave) CDsaB(aSession, flags);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
400 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
401 else
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
402 return new (ELeave) CDsaA(aSession);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
403 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
404
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
405
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
406 void CDsa::RecreateL()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
407 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
408 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
409
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
410 void CDsa::Free()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
411 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
412 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
413
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
414 TSize CDsa::WindowSize() const
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
415 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
416 TSize size = iSwSize;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
417 if(iStateFlags & EOrientation90)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
418 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
419 const TInt tmp = size.iWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
420 size.iWidth = size.iHeight;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
421 size.iHeight = tmp;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
422 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
423 return size;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
424 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
425
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
426 void CDsa::SetSuspend()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
427 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
428 iStateFlags |= ESdlThreadSuspend;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
429 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
430
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
431 void CDsa::ReleaseStop()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
432 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
433 iStateFlags &= ~ESdlThreadExplicitStop;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
434 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
435
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
436
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
437 TBool CDsa::Stopped() const
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
438 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
439 return (iStateFlags & ESdlThreadExplicitStop);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
440 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
441
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
442 void CDsa::SetOrientation(CSDL::TOrientationMode aOrientation)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
443 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
444 TInt flags = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
445 switch(aOrientation)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
446 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
447 case CSDL::EOrientation90:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
448 flags = EOrientation90;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
449 break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
450 case CSDL::EOrientation180:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
451 flags = EOrientation180;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
452 break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
453 case CSDL::EOrientation270:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
454 flags = EOrientation90 | EOrientation180;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
455 break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
456 case CSDL::EOrientation0:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
457 flags = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
458 break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
459 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
460 if(flags != (iStateFlags & EOrientationFlags))
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
461 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
462 iStateFlags |= EOrientationChanged;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
463 iNewFlags = flags; //cannot be set during drawing...
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
464 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
465 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
466
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
467 CDsa::~CDsa()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
468 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
469 if(iDsa != NULL)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
470 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
471 iDsa->Cancel();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
472 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
473 iOverlays.Close();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
474 delete iDsa;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
475 User::Free(iLut256);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
476 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
477
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
478 void CDsa::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
479 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
480 if(iDsa != NULL)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
481 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
482 iDsa->Cancel();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
483 delete iDsa;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
484 iDsa = NULL;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
485 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
486
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
487 iDsa = CDirectScreenAccess::NewL(
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
488 iSession,
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
489 aDevice,
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
490 aWindow,
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
491 *this);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
492
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
493 if(iLut256 == NULL)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
494 iLut256 = (TUint32*) User::AllocL(256 * sizeof(TUint32));
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
495 iTargetMode = aWindow.DisplayMode();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
496 iTargetBpp = BytesPerPixel(DisplayMode());
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
497 iScreenRect = TRect(aWindow.Position(), aWindow.Size());
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
498 SetTargetRect();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
499 RestartL();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
500 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
501
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
502 void CDsa::DrawOverlays()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
503 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
504 const TInt last = iOverlays.Count() - 1;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
505 for(TInt i = last; i >= 0 ; i--)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
506 iOverlays[i].iOverlay->Draw(*iDsa->Gc(), HwRect(), SwSize());
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
507 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
508
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
509 TInt CDsa::AppendOverlay(MOverlay& aOverlay, TInt aPriority)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
510 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
511 TInt i;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
512 for(i = 0; i < iOverlays.Count() && iOverlays[i].iPriority < aPriority; i++)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
513 {}
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
514 const TOverlay overlay = {&aOverlay, aPriority};
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
515 return iOverlays.Insert(overlay, i);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
516 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
517
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
518 TInt CDsa::RemoveOverlay(MOverlay& aOverlay)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
519 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
520 for(TInt i = 0; i < iOverlays.Count(); i++)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
521 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
522 if(iOverlays[i].iOverlay == &aOverlay)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
523 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
524 iOverlays.Remove(i);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
525 return KErrNone;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
526 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
527 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
528 return KErrNotFound;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
529 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
530
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
531 void CDsa::LockPalette(TBool aLock)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
532 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
533 if(aLock)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
534 iStateFlags |= EPaletteLocked;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
535 else
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
536 iStateFlags &= ~EPaletteLocked;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
537 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
538 TInt CDsa::SetPalette(TInt aFirst, TInt aCount, TUint32* aPalette)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
539 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
540 if(iLut256 == NULL)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
541 return KErrNotFound;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
542 const TInt count = aCount - aFirst;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
543 if(count > 256)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
544 return KErrArgument;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
545 if(iStateFlags & EPaletteLocked)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
546 return KErrNone;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
547 for(TInt i = aFirst; i < count; i++) //not so busy here:-)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
548 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
549 iLut256[i] = aPalette[i];
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
550 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
551 return KErrNone;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
552 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
553
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
554
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
555
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
556 void CDsa::RestartL()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
557 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
558 //const TBool active = iDsa->IsActive();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
559
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
560 //if(!active)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
561
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
562 iDsa->StartL();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
563
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
564 const RRegion* r = iDsa->DrawingRegion();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
565 const TRect rect = r->BoundingRect();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
566 iDsa->Gc()->SetClippingRegion(r);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
567
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
568 if(rect != iScreenRect)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
569 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
570 // iDsa->Cancel();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
571 return ;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
572 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
573
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
574
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
575
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
576 //iScreenRect = rect; //to ensure properly set, albeit may not(?) match to value SDL has - therefore may has to clip
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
577 //targetrect shall no change
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
578 SetTargetRect();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
579 RecreateL();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
580
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
581 iStateFlags |= ERunning;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
582
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
583 ReleaseStop();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
584 if(iStateFlags & ESdlThreadSuspend)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
585 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
586 EpocSdlEnv::Resume();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
587 iStateFlags &= ~ ESdlThreadSuspend;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
588 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
589 EpocSdlEnv::ObserverEvent(MSDLObserver::EEventWindowReserved);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
590 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
591
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
592 CDsa::CDsa(RWsSession& aSession) :
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
593 iSession(aSession),
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
594 iStateFlags(0)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
595 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
596 // CActiveScheduler::Add(this);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
597 iCFTable[0] = CopyMem;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
598 iCFTable[1] = CopyMemFlipReversed;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
599 iCFTable[2] = CopyMemReversed;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
600 iCFTable[3] = CopyMemFlip;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
601
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
602 iCFTable[4] = Copy256;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
603 iCFTable[5] = Copy256FlipReversed;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
604 iCFTable[6] = Copy256Reversed;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
605 iCFTable[7] = Copy256Flip;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
606
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
607
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
608 iCFTable[8] = CopySlow;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
609 iCFTable[9] = CopySlowFlipReversed;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
610 iCFTable[10] = CopySlowReversed;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
611 iCFTable[11] = CopySlowFlip;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
612 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
613
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
614 RWsSession& CDsa::Session()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
615 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
616 return iSession;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
617 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
618
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
619 TInt CDsa::RedrawRequest()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
620 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
621 if(!(iStateFlags & (EUpdating) && (iStateFlags & ERunning)))
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
622 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
623 return ExternalUpdate();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
624 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
625 return KErrNotReady;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
626 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
627
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
628 TUint8* CDsa::LockHwSurface()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
629 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
630 if((iStateFlags & EUpdating) == 0) //else frame is skipped
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
631 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
632 return LockSurface();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
633 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
634 return NULL;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
635 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
636
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
637 /*
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
638 void CDsa::RunL()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
639 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
640 iStateFlags &= ~EUpdating;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
641 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
642
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
643
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
644 void CDsa::DoCancel()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
645 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
646 iStateFlags &= ~EUpdating;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
647 //nothing can do, just wait?
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
648 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
649 */
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
650
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
651
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
652 TInt CDsa::AllocSurface(TBool aHwSurface, const TSize& aSize, TDisplayMode aMode)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
653 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
654 if(aHwSurface && aMode != DisplayMode())
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
655 return KErrArgument;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
656
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
657 iSourceMode = aMode;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
658
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
659 iSourceBpp = BytesPerPixel(aMode);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
660
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
661 const TSize size = WindowSize();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
662 if(aSize.iWidth > size.iWidth)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
663 return KErrTooBig;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
664 if(aSize.iHeight > size.iHeight)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
665 return KErrTooBig;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
666
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
667 TRAPD(err, CreateSurfaceL());
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
668 if(err != KErrNone)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
669 return err;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
670
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
671 SetCopyFunction();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
672
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
673 return KErrNone;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
674 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
675
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
676
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
677 void CDsa::CreateZoomerL(const TSize& aSize)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
678 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
679 iSwSize = aSize;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
680 iStateFlags |= EResizeRequest;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
681 CreateSurfaceL();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
682 SetTargetRect();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
683 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
684
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
685
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
686 /*
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
687 void SaveBmp(const TDesC& aName, const TAny* aData, TInt aLength, const TSize& aSz, TDisplayMode aMode)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
688 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
689 CFbsBitmap* s = new CFbsBitmap();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
690 s->Create(aSz, aMode);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
691 s->LockHeap();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
692 TUint32* addr = s->DataAddress();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
693 Mem::Copy(addr, aData, aLength);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
694 s->UnlockHeap();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
695 s->Save(aName);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
696 s->Reset();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
697 delete s;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
698 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
699
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
700 void SaveBmp(const TDesC& aName, const TUint32* aData, const TSize& aSz)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
701 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
702 CFbsBitmap* s = new CFbsBitmap();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
703 s->Create(aSz, EColor64K);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
704 TBitmapUtil bmp(s);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
705 bmp.Begin(TPoint(0, 0));
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
706 for(TInt j = 0; j < aSz.iHeight; j++)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
707 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
708 bmp.SetPos(TPoint(0, j));
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
709 for(TInt i = 0; i < aSz.iWidth; i++)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
710 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
711 bmp.SetPixel(*aData);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
712 aData++;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
713 bmp.IncXPos();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
714 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
715 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
716 bmp.End();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
717 s->Save(aName);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
718 s->Reset();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
719 delete s;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
720 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
721
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
722 TBuf<16> FooName(TInt aFoo)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
723 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
724 TBuf<16> b;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
725 b.Format(_L("C:\\pic%d.mbm"), aFoo);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
726 return b;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
727 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
728
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
729 void ClipCopy(TUint8* aTarget, const TUint8* aSource, const TRect& aRect, const TPoint& aTargetPos)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
730 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
731 const TInt iSourceBpp = 1;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
732 const TInt iTargetBpp = 4;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
733 const TInt iScanLineWidth = 800;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
734
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
735 TUint8* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
736 const TUint8* source = aSource;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
737 const TInt lineWidth = aRect.Width();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
738 source += iSourceBpp * (aRect.iTl.iY * lineWidth);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
739 const TInt sourceStartOffset = iSourceBpp * aRect.iTl.iX;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
740 source += sourceStartOffset;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
741 target += iTargetBpp * ((aTargetPos.iY + aRect.iTl.iY ) * lineWidth);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
742 const TInt targetStartOffset = iTargetBpp * (aRect.iTl.iX + aTargetPos.iX);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
743 target += targetStartOffset;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
744 TUint32* targetPtr = reinterpret_cast<TUint32*>(target);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
745 const TInt targetWidth = iScanLineWidth >> 2;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
746 const TInt height = aRect.Height();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
747 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
748 */
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
749 /*
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
750 void CDsa::ClipCopy(TUint8* aTarget,
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
751 const TUint8* aSource,
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
752 const TRect& aUpdateRect,
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
753 const TRect& aSourceRect) const
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
754 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
755 //TUint8* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
756 const TUint32* source = (const TUint32*) aSource;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
757 const TInt lineWidth = aSourceRect.Width();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
758
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
759 source += (aUpdateRect.iTl.iY * lineWidth);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
760 const TInt sourceStartOffset = aUpdateRect.iTl.iX;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
761 source += sourceStartOffset;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
762
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
763 TUint32* targetPtr = reinterpret_cast<TUint32*>(aTarget);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
764
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
765 targetPtr += (aSourceRect.iTl.iY + aUpdateRect.iTl.iY ) * SwSize().iWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
766 const TInt targetStartOffset = (aUpdateRect.iTl.iX + aSourceRect.iTl.iX);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
767
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
768 targetPtr += targetStartOffset;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
769
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
770 // TUint32* targetPtr = reinterpret_cast<TUint32*>(target);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
771
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
772 const TInt targetWidth32 = SwSize().iWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
773
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
774 const TInt height = aUpdateRect.Height();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
775
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
776 const TInt lineMove = iStateFlags & EOrientation90 ? 1 : lineWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
777 const TInt copyLen = aUpdateRect.Width();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
778
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
779
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
780 if(iStateFlags & EOrientation180)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
781 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
782
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
783 targetPtr += targetWidth32 * (height - 1);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
784
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
785 for(TInt i = 0; i < height; i++) //source is always smaller
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
786 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
787 iCopyFunction(*this, targetPtr, (TUint8*)source, copyLen, height);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
788 source += lineMove;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
789 targetPtr -= targetWidth32;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
790 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
791 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
792 else
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
793 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
794
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
795
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
796 for(TInt i = 0; i < height; i++) //source is always smaller
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
797 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
798 iCopyFunction(*this, targetPtr, (TUint8*)source, copyLen, height);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
799 source += lineMove;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
800 targetPtr += targetWidth32; // >> 2;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
801 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
802 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
803
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
804 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
805
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
806 */
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
807
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
808 void CDsa::ClipCopy(TUint8* aTarget, const TUint8* aSource, const TRect& aRect, const TPoint& aTargetPos) const
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
809 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
810 TUint8* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
811 const TUint8* source = aSource;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
812 const TInt lineWidth = aRect.Width();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
813 source += iSourceBpp * (aRect.iTl.iY * lineWidth);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
814 TInt sourceStartOffset = iSourceBpp * aRect.iTl.iX;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
815 source += sourceStartOffset;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
816 target += iTargetBpp * ((aTargetPos.iY + aRect.iTl.iY ) * lineWidth);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
817 TInt targetStartOffset = iTargetBpp * (aRect.iTl.iX + aTargetPos.iX);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
818 target += targetStartOffset;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
819 TUint32* targetPtr = reinterpret_cast<TUint32*>(target);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
820 const TInt targetWidth = iScanLineWidth >> 2;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
821 const TInt height = aRect.Height();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
822
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
823 TInt lineMove = iStateFlags & EOrientation90 ? 1 : lineWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
824
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
825 if(iStateFlags & EOrientation180)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
826 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
827
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
828 targetPtr += targetWidth * (height - 1);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
829
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
830 for(TInt i = 0; i < height; i++) //source is always smaller
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
831 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
832 iCopyFunction(*this, targetPtr, source, lineWidth, height);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
833 source += lineMove;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
834 targetPtr -= targetWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
835 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
836 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
837 else
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
838 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
839
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
840
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
841 for(TInt i = 0; i < height; i++) //source is always smaller
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
842 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
843 iCopyFunction(*this, targetPtr, source, lineWidth, height);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
844 source += lineMove;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
845 targetPtr += targetWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
846 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
847 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
848
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
849 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
850
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
851
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
852
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
853 /*
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
854 void CDsa::ClipCopy(TUint8* aTarget,
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
855 const TUint8* aSource,
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
856 const TRect& aUpdateRect,
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
857 const TRect& aSourceRect) const
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
858 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
859 const TDsa dsa(*this);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
860 switch(iSourceBpp)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
861 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
862 case 1:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
863 ::ClipCopy<TUint32, TUint8>(dsa, aTarget, aSource, aUpdateRect, aSourceRect);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
864 break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
865 case 2:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
866 ::ClipCopy<TUint32, TUint16>(dsa, aTarget, aSource, aUpdateRect, aSourceRect);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
867 break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
868 case 4:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
869 ::ClipCopy<TUint32, TUint32>(dsa, aTarget, aSource, aUpdateRect, aSourceRect);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
870 break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
871 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
872 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
873
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
874
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
875 */
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
876
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
877
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
878
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
879 void CDsa::Wipe() //dont call in drawing
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
880 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
881 if(IsDsaAvailable())
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
882 Wipe(iTargetBpp * SwSize().iWidth * SwSize().iHeight);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
883 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
884
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
885 void CDsa::SetCopyFunction()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
886 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
887 //calculate offset to correct function in iCFTable according to given parameters
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
888 TInt function = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
889 const TInt KCopyFunctions = 4;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
890 const TInt KOffsetToNative = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
891 const TInt KOffsetTo256 = KOffsetToNative + KCopyFunctions;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
892 const TInt KOffsetToOtherModes = KOffsetTo256 + KCopyFunctions;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
893 const TInt KOffsetTo90Functions = 1;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
894 const TInt KOffsetTo180Functions = 2;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
895
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
896 if(iSourceMode == DisplayMode())
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
897 function = KOffsetToNative; //0
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
898 else if(iSourceMode == EColor256)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
899 function = KOffsetTo256; //4
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
900 else
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
901 function = KOffsetToOtherModes; //8
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
902
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
903 if(iStateFlags & EOrientation90)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
904 function += KOffsetTo90Functions; // + 1
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
905 if(iStateFlags & EOrientation180)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
906 function += KOffsetTo180Functions; //+ 2
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
907
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
908 iCopyFunction = iCFTable[function];
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
909
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
910 Wipe();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
911 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
912
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
913 inline void Rotate(TRect& aRect)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
914 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
915 const TInt dx = aRect.iBr.iX - aRect.iTl.iX;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
916 const TInt dy = aRect.iBr.iY - aRect.iTl.iY;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
917
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
918 aRect.iBr.iX = aRect.iTl.iX + dy;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
919 aRect.iBr.iY = aRect.iTl.iY + dx;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
920
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
921 const TInt tmp = aRect.iTl.iX;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
922 aRect.iTl.iX = aRect.iTl.iY;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
923 aRect.iTl.iY = tmp;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
924 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
925
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
926 /*
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
927 int bar = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
928 */
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
929 /*
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
930 TBool CDsa::AddUpdateRect(const TUint8* aBits, const TRect& aUpdateRect, const TRect& aRect)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
931 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
932
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
933 if(iStateFlags & EOrientationChanged)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
934 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
935 iStateFlags &= ~EOrientationFlags;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
936 iStateFlags |= iNewFlags;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
937 SetCopyFunction();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
938 iStateFlags &= ~EOrientationChanged;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
939 EpocSdlEnv::WaitDeviceChange();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
940 return EFalse; //skip this frame as data is may be changed
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
941 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
942
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
943 if(iTargetAddr == NULL)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
944 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
945 iTargetAddr = LockHwSurface();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
946 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
947
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
948 TUint8* target = iTargetAddr;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
949 if(target == NULL)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
950 return EFalse;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
951
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
952
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
953 TRect targetRect = TRect(TPoint(0, 0), SwSize());
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
954
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
955 TRect sourceRect = aRect;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
956 TRect updateRect = aUpdateRect;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
957
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
958 // TPoint move(0, 0);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
959
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
960
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
961 if(iStateFlags & EOrientation90)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
962 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
963 Rotate(sourceRect);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
964 Rotate(updateRect);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
965 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
966
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
967 if(iSourceMode != DisplayMode() || targetRect != sourceRect || targetRect != updateRect || ((iStateFlags & EOrientationFlags) != 0))
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
968 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
969 sourceRect.Intersection(targetRect); //so source always smaller or equal than target
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
970 //updateRect.Intersection(targetRect);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
971 ClipCopy(target, aBits, updateRect, sourceRect);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
972 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
973 else
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
974 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
975 const TInt byteCount = aRect.Width() * aRect.Height() * iSourceBpp; //this could be stored
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
976 Mem::Copy(target, aBits, byteCount);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
977 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
978
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
979 return ETrue;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
980 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
981 */
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
982
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
983 TBool CDsa::AddUpdateRect(const TUint8* aBits, const TRect& aUpdateRect, const TRect& aRect)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
984 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
985
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
986 if(iStateFlags & EOrientationChanged)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
987 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
988 iStateFlags &= ~EOrientationFlags;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
989 iStateFlags |= iNewFlags;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
990 SetCopyFunction();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
991 iStateFlags &= ~EOrientationChanged;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
992 EpocSdlEnv::WaitDeviceChange();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
993 return EFalse; //skip this frame as data is may be changed
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
994 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
995
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
996 if(iTargetAddr == NULL)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
997 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
998 iTargetAddr = LockHwSurface();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
999 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1000 TUint8* target = iTargetAddr;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1001 if(target == NULL)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1002 return EFalse;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1003
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1004
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1005 TRect targetRect = Rect();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1006 TRect sourceRect = aRect;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1007 TRect updateRect = aUpdateRect;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1008
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1009 if(iStateFlags & EOrientation90)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1010 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1011 Rotate(sourceRect);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1012 Rotate(updateRect);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1013 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1014
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1015 if(iSourceMode != DisplayMode() || targetRect != sourceRect || targetRect != updateRect || ((iStateFlags & EOrientationFlags) != 0))
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1016 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1017 sourceRect.Intersection(targetRect); //so source always smaller or equal than target
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1018 updateRect.Intersection(targetRect);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1019 ClipCopy(target, aBits, updateRect, sourceRect.iTl);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1020 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1021 else
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1022 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1023 const TInt byteCount = aRect.Width() * aRect.Height() * iSourceBpp; //this could be stored
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1024 Mem::Copy(target, aBits, byteCount);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1025 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1026
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1027 return ETrue;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1028 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1029 void CDsa::UpdateSwSurface()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1030 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1031 iTargetAddr = NULL;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1032 UnlockHwSurface(); //could be faster if does not use AO, but only check status before redraw, then no context switch needed
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1033 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1034
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1035
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1036 void CDsa::Resume()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1037 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1038 if(Stopped())
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1039 Restart(RDirectScreenAccess::ETerminateRegion);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1040 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1041
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1042 void CDsa::DoStop()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1043 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1044 if(IsDsaAvailable())
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1045 iStateFlags |= ESdlThreadExplicitStop;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1046 Stop();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1047 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1048
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1049 void CDsa::Stop()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1050 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1051 iStateFlags &= ~ERunning;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1052 // Cancel(); //can be called only from main!
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1053 iDsa->Cancel();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1054 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1055
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1056 void CDsa::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1057 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1058 // iStateFlags |= EChangeNotify;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1059 Stop();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1060 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1061
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1062 void CDsa::Restart(RDirectScreenAccess::TTerminationReasons aReason)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1063 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1064 if(aReason == RDirectScreenAccess::ETerminateRegion) //auto restart
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1065 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1066 TRAPD(err, RestartL());
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1067 PANIC_IF_ERROR(err);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1068 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1069 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1070
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1071 void CDsa::SetBlitter(MBlitter* aBlitter)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1072 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1073 iBlitter = aBlitter;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1074 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1075
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1076
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1077 TPoint CDsa::WindowCoordinates(const TPoint& aPoint) const
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1078 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1079 TPoint pos = aPoint - iScreenRect.iTl;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1080 const TSize asz = iScreenRect.Size();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1081 if(iStateFlags & EOrientation180)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1082 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1083 pos.iX = asz.iWidth - pos.iX;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1084 pos.iY = asz.iHeight - pos.iY;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1085 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1086 if(iStateFlags & EOrientation90)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1087 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1088 pos.iX = aPoint.iY;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1089 pos.iY = aPoint.iX;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1090 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1091 pos.iX <<= 16;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1092 pos.iY <<= 16;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1093 pos.iX /= asz.iWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1094 pos.iY /= asz.iHeight;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1095 pos.iX *= iSwSize.iWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1096 pos.iY *= iSwSize.iHeight;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1097 pos.iX >>= 16;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1098 pos.iY >>= 16;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1099 return pos;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1100 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1101
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1102 void CDsa::SetTargetRect()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1103 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1104 iTargetRect = iScreenRect;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1105 if(iStateFlags & EResizeRequest && EpocSdlEnv::Flags(CSDL::EAllowImageResizeKeepRatio))
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1106 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1107 const TSize asz = iScreenRect.Size();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1108 const TSize sz = iSwSize;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1109
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1110 TRect rect;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1111
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1112 const TInt dh = (sz.iHeight << 16) / sz.iWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1113
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1114 if((asz.iWidth * dh ) >> 16 <= asz.iHeight)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1115 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1116 rect.SetRect(TPoint(0, 0), TSize(asz.iWidth, (asz.iWidth * dh) >> 16));
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1117 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1118 else
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1119 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1120 const TInt dw = (sz.iWidth << 16) / sz.iHeight;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1121 rect.SetRect(TPoint(0, 0), TSize((asz.iHeight * dw) >> 16, asz.iHeight));
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1122 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1123 rect.Move((asz.iWidth - rect.Size().iWidth) >> 1, (asz.iHeight - rect.Size().iHeight) >> 1);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1124
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1125 iTargetRect = rect;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1126 iTargetRect.Move(iScreenRect.iTl);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1127
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1128 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1129 if(!(iStateFlags & EResizeRequest))
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1130 iSwSize = iScreenRect.Size();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1131 // iScanLineWidth = /*iTargetBpp **/ SwSize().iWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1132 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1133
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1134 /*)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1135 TBool CDsa::ChangeTrigger()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1136 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1137 const TBool change = iStateFlags & EChangeNotify;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1138 iStateFlags &= ~EChangeNotify;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1139 return change;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1140 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1141 */
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1142 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1143
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1144 void CDsa::Copy256(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1145 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1146 TUint32* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1147 const TUint32* endt = target + aBytes;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1148 const TUint8* source = aSource;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1149 while(target < endt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1150 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1151 *target++ = aDsa.iLut256[*source++];
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1152 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1153 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1154
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1155 void CDsa::Copy256Reversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1156 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1157 const TUint32* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1158 TUint32* endt = aTarget + aBytes;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1159 const TUint8* source = aSource;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1160 while(target < endt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1161 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1162 *(--endt) = aDsa.iLut256[*source++];
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1163 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1164 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1165
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1166 void CDsa::Copy256Flip(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1167 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1168 TUint32* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1169 const TUint32* endt = target + aBytes;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1170 const TUint8* column = aSource;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1171
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1172 while(target < endt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1173 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1174 *target++ = aDsa.iLut256[*column];
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1175 column += aLineLen;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1176 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1177 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1178
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1179 void CDsa::Copy256FlipReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1180 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1181 const TUint32* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1182 TUint32* endt = aTarget + aBytes;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1183 const TUint8* column = aSource;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1184
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1185 while(target < endt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1186 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1187 *(--endt) = aDsa.iLut256[*column];
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1188 column += aLineLen;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1189 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1190 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1191
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1192 void CDsa::CopyMem(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1193 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1194 const TUint32* src = reinterpret_cast<const TUint32*>(aSource);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1195 Mem::Copy(aTarget, src, aBytes << 2);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1196 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1197
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1198 void CDsa::CopyMemFlip(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1199 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1200 TUint32* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1201 const TUint32* endt = target + aBytes;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1202 const TUint32* column = reinterpret_cast<const TUint32*>(aSource);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1203
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1204 while(target < endt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1205 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1206 *target++ = *column;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1207 column += aLineLen;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1208 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1209 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1210
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1211 void CDsa::CopyMemReversed(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1212 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1213 const TUint32* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1214 TUint32* endt = aTarget + aBytes;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1215 const TUint32* source = reinterpret_cast<const TUint32*>(aSource);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1216 while(target < endt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1217 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1218 *(--endt) = *source++;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1219 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1220 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1221
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1222
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1223 void CDsa::CopyMemFlipReversed(const CDsa& /*aDsa*/, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1224 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1225 const TUint32* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1226 TUint32* endt = aTarget + aBytes;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1227 const TUint32* column = reinterpret_cast<const TUint32*>(aSource);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1228
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1229 while(target < endt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1230 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1231 *(--endt) = *column;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1232 column += aLineLen;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1233 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1234 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1235
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1236 /*
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1237
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1238 LOCAL_C TRgb rgb16MA(TInt aValue)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1239 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1240 return TRgb::Color16MA(aValue);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1241 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1242 */
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1243 NONSHARABLE_CLASS(MRgbCopy)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1244 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1245 public:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1246 virtual void Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed) = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1247 virtual void FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed) = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1248 };
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1249
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1250 template <class T>
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1251 NONSHARABLE_CLASS(TRgbCopy) : public MRgbCopy
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1252 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1253 public:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1254 TRgbCopy(TDisplayMode aMode);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1255 void* operator new(TUint aBytes, TAny* aMem);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1256 void Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1257 void FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1258 static TUint32 Gray256(const TUint8& aPixel);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1259 static TUint32 Color256(const TUint8& aPixel);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1260 static TUint32 Color4K(const TUint16& aPixel);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1261 static TUint32 Color64K(const TUint16& aPixel);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1262 static TUint32 Color16M(const TUint32& aPixel);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1263 static TUint32 Color16MU(const TUint32& aPixel);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1264 static TUint32 Color16MA(const TUint32& aPixel);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1265 private:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1266 typedef TUint32 (*TRgbFunc) (const T& aValue);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1267 TRgbFunc iFunc;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1268 };
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1269
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1270
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1271 template <class T>
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1272 void* TRgbCopy<T>::operator new(TUint /*aBytes*/, TAny* aMem)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1273 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1274 return aMem;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1275 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1276
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1277 template <class T>
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1278 TRgbCopy<T>::TRgbCopy(TDisplayMode aMode)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1279 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1280 switch(aMode)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1281 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1282 case EGray256 : iFunc = (TRgbFunc) Gray256; break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1283 case EColor256 : iFunc = (TRgbFunc) Color256; break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1284 case EColor4K : iFunc = (TRgbFunc) Color4K; break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1285 case EColor64K : iFunc = (TRgbFunc) Color64K; break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1286 case EColor16M : iFunc = (TRgbFunc) Color16M; break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1287 case EColor16MU : iFunc = (TRgbFunc) Color16MU; break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1288 case EColor16MA : iFunc = (TRgbFunc) Color16MA; break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1289 default:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1290 PANIC(KErrNotSupported);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1291 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1292 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1293
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1294 template <class T>
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1295 void TRgbCopy<T>::Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1296 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1297 const T* source = reinterpret_cast<const T*>(aSource);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1298 TUint32* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1299 TUint32* endt = target + aBytes;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1300
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1301 if(aReversed)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1302 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1303 while(target < endt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1304 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1305 const T value = *source++;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1306 *(--endt) = iFunc(value);//iFunc(value).Value();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1307 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1308 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1309 else
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1310 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1311 while(target < endt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1312 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1313 const T value = *source++;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1314 *target++ = iFunc(value);//iFunc(value).Value();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1315 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1316 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1317 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1318
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1319 template <class T>
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1320 void TRgbCopy<T>::FlipCopy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen, TBool aReversed)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1321 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1322 const T* column = reinterpret_cast<const T*>(aSource);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1323 TUint32* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1324 TUint32* endt = target + aBytes;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1325
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1326 if(aReversed)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1327 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1328 while(target < endt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1329 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1330 *(--endt) = iFunc(*column);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1331 column += aLineLen;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1332 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1333 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1334 else
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1335 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1336 while(target < endt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1337 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1338 *target++ = iFunc(*column);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1339 column += aLineLen;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1340 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1341 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1342 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1343
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1344 template <class T> TUint32 TRgbCopy<T>::Gray256(const TUint8& aPixel)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1345 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1346 const TUint32 px = aPixel << 16 | aPixel << 8 | aPixel;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1347 return px;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1348 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1349
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1350 template <class T> TUint32 TRgbCopy<T>::Color256(const TUint8& aPixel)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1351 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1352 return TRgb::Color256(aPixel).Value();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1353 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1354
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1355 template <class T> TUint32 TRgbCopy<T>::Color4K(const TUint16& aPixel)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1356 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1357 TUint32 col = (aPixel & 0xF00) << 12;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1358 col |= (aPixel & 0xF00) << 8;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1359
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1360 col |= (aPixel & 0x0F0) << 8;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1361 col |= (aPixel & 0x0F0);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1362
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1363 col |= (aPixel & 0x00F) << 4;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1364 col |= (aPixel & 0x00F);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1365
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1366 return col;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1367 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1368
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1369 template <class T> TUint32 TRgbCopy<T>::Color64K(const TUint16& aPixel)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1370 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1371 TUint32 col = (aPixel & 0xF800)<< 8;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1372 col |= (aPixel & 0xE000) << 3;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1373
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1374 col |= (aPixel & 0x07E0) << 5;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1375 col |= (aPixel & 0xC0) >> 1;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1376
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1377 col |= (aPixel & 0x07E0) << 3;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1378 col |= (aPixel & 0x1C) >> 2;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1379
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1380 return col;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1381 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1382
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1383 template <class T> TUint32 TRgbCopy<T>::Color16M(const TUint32& aPixel)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1384 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1385 return TRgb::Color16M(aPixel).Value();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1386 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1387
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1388 template <class T> TUint32 TRgbCopy<T>::Color16MU(const TUint32& aPixel)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1389 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1390 return TRgb::Color16MU(aPixel).Value();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1391 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1392
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1393 template <class T> TUint32 TRgbCopy<T>::Color16MA(const TUint32& aPixel)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1394 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1395 return TRgb::Color16MA(aPixel).Value();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1396 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1397
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1398 typedef TUint64 TStackMem;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1399
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1400 LOCAL_C MRgbCopy* GetCopy(TAny* mem, TDisplayMode aMode)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1401 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1402 if(aMode == EColor256 || aMode == EGray256)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1403 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1404 return new (mem) TRgbCopy<TUint8>(aMode);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1405 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1406 if(aMode == EColor4K || aMode == EColor64K)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1407 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1408 return new (mem) TRgbCopy<TUint16>(aMode);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1409 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1410 if(aMode == EColor16M || aMode == EColor16MU || aMode == EColor16MA)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1411 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1412 return new (mem) TRgbCopy<TUint32>(aMode);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1413 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1414 PANIC(KErrNotSupported);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1415 return NULL;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1416 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1417
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1418
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1419 void CDsa::CopySlowFlipReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1420 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1421 TStackMem mem = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1422 GetCopy(&mem, aDsa.iSourceMode)->FlipCopy(aTarget, aSource, aBytes, aLineLen, ETrue);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1423 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1424
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1425 void CDsa::CopySlowFlip(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt aLineLen)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1426 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1427 TStackMem mem = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1428 GetCopy(&mem, aDsa.iSourceMode)->FlipCopy(aTarget, aSource, aBytes, aLineLen, EFalse);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1429 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1430
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1431 void CDsa::CopySlow(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1432 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1433 TStackMem mem = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1434 GetCopy(&mem, aDsa.iSourceMode)->Copy(aTarget, aSource, aBytes, EFalse);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1435 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1436
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1437 void CDsa::CopySlowReversed(const CDsa& aDsa, TUint32* aTarget, const TUint8* aSource, TInt aBytes, TInt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1438 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1439 TStackMem mem = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1440 GetCopy(&mem, aDsa.iSourceMode)->Copy(aTarget, aSource, aBytes, ETrue);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1441 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1442
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1443 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////7