1 /*
2 SDL - Simple DirectMedia Layer
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
18
19 */
20
21 /*
22 epoc sdl.cpp
23 Symbian OS services for SDL
24
25 Markus Mertama
26 */
27
28 #ifndef EPOCSDL_H
29 #define EPOCSDL_H
30
31
32 #include<e32def.h>
33
34 #include<e32std.h>
35 #include<gdi.h>
36 #include<w32std.h>
37 #include"SDL_config_symbian.h"
38 #include<sdlepocapi.h>
39
40
41 //#undef DEBUG_TRACE_ENABLED
42 #define TRACE_TO_FILE
43 #ifdef DEBUG_TRACE_ENABLED
44 #define SDL_TRACE(error_str) RDebug_Print(error_str, (void*) NULL)
45 #define SDL_TRACE1(error_str, param) RDebug_Print(error_str, (void*) (param))
46 #define SDL_MEM() SDL_TRACE1("Free memory=%d", Debug_AvailMem())
47 extern "C"
48 {
49 void RDebug_Print(char* error_str, void* param);
50 void RDebug_Print_b(char* error_str, void* param);
51 int Debug_AvailMem();
52 }
53 #else
54 #define SDL_TRACE(error_str)
55 #define SDL_TRACE1(error_str, param)
56 #define SDL_MEM()
57 #endif
58
59 #define PANIC(x) Panic(x, __LINE__)
60 #define PANIC_IF_ERROR(x) (x == KErrNone || Panic(x, __LINE__))
61
62 TInt Panic(TInt aErr, TInt aLine);
63
64 const TInt KPointerBufferSize = 32;
65
NONSHARABLE_CLASS(MEventQueue)66 NONSHARABLE_CLASS(MEventQueue)
67 {
68 public:
69 virtual TInt Append(const TWsEvent& aEvent) = 0;
70 // virtual const TWsEvent& Top() = 0;
71 virtual TBool HasData() = 0;
72 // virtual TInt Shift() = 0;
73 virtual const TWsEvent& Shift() = 0;
74 virtual void Lock() = 0;
75 virtual void Unlock() = 0;
76 };
77
78
79 //class CEikonEnv;
80
81 typedef void (*TSdlCleanupOperation) (TAny* aThis);
82
NONSHARABLE_CLASS(TSdlCleanupItem)83 NONSHARABLE_CLASS(TSdlCleanupItem)
84 {
85 public:
86 TSdlCleanupItem(TSdlCleanupOperation aOperation, TAny* aItem, TBool aThreadCleanup = ETrue);
87 public:
88 TSdlCleanupOperation iOperation;
89 TAny* iItem;
90 TThreadId iThread;
91 };
92
93
NONSHARABLE_CLASS(EpocSdlEnv)94 NONSHARABLE_CLASS(EpocSdlEnv)
95 {
96 public:
97 enum {EDisableKeyBlocking = 100, ESetAppOrientation, ELastService};
98 static void Request(TInt aService);
99 static MEventQueue& EventQueue();
100 static void CreateZoomer(const TSize& aRequestedSize);
101 static TSize WindowSize();
102 static TDisplayMode DisplayMode();
103 static TPointerCursorMode PointerMode();
104 static TBool Flags(TInt aFlag);
105 static TInt Argc();
106 static char** Argv();
107 static TBool IsDsaAvailable();
108 // static void Dsa(const TPoint& aPoint, const CFbsBitmap& aBmp);
109 static TInt AllocSwSurface(const TSize& aSize, TDisplayMode aMode);
110 static TInt AllocHwSurface(const TSize& aSize, TDisplayMode aMode);
111 static void UnlockHwSurface();
112 static TUint8* LockHwSurface();
113 static void UpdateSwSurface();
114 static TBool AddUpdateRect(TUint8* aAddress, const TRect& aUpdateRect, const TRect& aTargetRect);
115 static void PanicMain(TInt aErr);
116 static void PanicMain(const TDesC& aInfo, TInt aErr);
117 // static void WaitDeviceChange();
118 static TInt SetPalette(TInt aFirstcolor, TInt aColorCount, TUint32* aPalette);
119 static void ObserverEvent(TInt aService, TInt aParam = 0);
120 static void WaitDsaAvailable();
121 static void LockPalette(TBool aLock);
122 static void DoResume(TBool aInternal, TBool aRendezvous = EFalse);
123 static void DoSuspend(TBool aInternal);
124 static TInt AppendCleanupItem(const TSdlCleanupItem& aItem);
125 static void RemoveCleanupItem(TAny* aItem);
126 static void CleanupItems();
127 // static void SetWaitDsa();
128 static TPoint WindowCoordinates(const TPoint& aPoint);
129 static void FreeSurface();
130 static TInt ApplyGlesDsa();
131 static RWindow* Window();
132 static void SetOrientation(CSDL::TOrientationMode);
133 static TBool AutoOrientation(const TSize& aSize);
134 static TInt SetAppOrientation(CSDL::TAppOrientation);
135 static TSize ScreenSize();
136 static void PostUpdate();
137 static TInt StackSize();
138 static TBool IsVideoThread();
139 // static void ScreenSizeChanged();
140 static void EnableDraw();
141 static void DisableDraw();
142 static void ResumeDsa();
143 static TUint32 BgColor();
144 static void RemoveThread(TInt aThreadId);
145 static void AppendThread(TInt aThreadId);
146 static TBool IsSuspend();
147 static void ScreenSizeChanged();
148 static void UpdateHwSurface();
149 // static CSDL::TAppOrientation AppOrientation();
150 // static TInt SetVolume(TInt aVolume);
151 // static TInt Volume();
152 // static TInt MaxVolume();
153 };
154
155 #endif
156
157
158