annotate src/video/symbian/EKA2/dsa_old.cpp @ 4157:baf615f9f2a0 SDL-1.2

Date: Thu, 16 Oct 2008 20:27:34 +0400 From: "Ilya Kasnacheev" <ilya.kasnacheev@gmail.com> To: sdl@lists.libsdl.org Subject: [SDL] SDL for Windows CE: a few GAPI patches Hi *! I've just ported a POWDER roguelike ( http://www.zincland.com/powder/ ) to Windows CE (PDAs, Windows Mobile/Pocket PC). To do that, I had to get libsdl working. Thanks for the awesome project files, it built without a hitch. Nevertheless, I've found quite a few bugs in Windows CE (GAPI) SDL implementation, which I've solved and now present as a serie of patches. I'll try carefully annotate them. Please annotate them so I can work toward accepting them into the main source tree since without them SDL isn't really working on Windows CE (I wonder why nobody fixed them before, btw: why isn't SDL popular as a way to develop Windows CE games? Where are no ports?) These changes can't be considered flawless, but they can be considered working because I've yet to hear complains about things I fixed and POWDER build for Windows CE is now considered stable. Note: my comments start with !!, delete them before applying. diff -bru SDL-1.2.13/src/video/gapi/SDL_gapivideo.c SDL-1.2.13-new/src/video/gapi/SDL_gapivideo.c --- SDL-1.2.13/src/video/gapi/SDL_gapivideo.c 2007-12-31 07:48:00.000000000 +0300 +++ SDL-1.2.13-new/src/video/gapi/SDL_gapivideo.c 2008-10-16 20:02:11.000000000 +0400 @@ -643,6 +643,7 @@ } gapi->userOrientation = SDL_ORIENTATION_UP; + gapi->systemOrientation = SDL_ORIENTATION_UP; video->flags = SDL_FULLSCREEN; /* Clear flags, GAPI supports fullscreen only */ /* GAPI or VGA? */ @@ -661,18 +662,21 @@ } /* detect user landscape mode */ - if( (width > height) && (GetSystemMetrics(SM_CXSCREEN) < GetSystemMetrics(SM_CYSCREEN))) + if( (width > height) && (gapi->gxProperties.cxWidth < gapi->gxProperties.cyHeight)) gapi->userOrientation = SDL_ORIENTATION_RIGHT; + if(GetSystemMetrics(SM_CYSCREEN) < GetSystemMetrics(SM_CXSCREEN)) + gapi->systemOrientation = SDL_ORIENTATION_RIGHT; + /* shall we apply hires fix? for example when we do not use hires resource */ gapi->hiresFix = 0; - if( gapi->userOrientation == SDL_ORIENTATION_RIGHT ) + if( gapi->systemOrientation == gapi->userOrientation ) { - if( (width > GetSystemMetrics(SM_CYSCREEN)) || (height > GetSystemMetrics(SM_CXSCREEN))) + if( (width > GetSystemMetrics(SM_CXSCREEN)) || (height > GetSystemMetrics(SM_CYSCREEN))) gapi->hiresFix = 1; } else - if( (width > GetSystemMetrics(SM_CXSCREEN)) || (height > GetSystemMetrics(SM_CYSCREEN))) - if( !((width == GetSystemMetrics(SM_CYSCREEN)) && (height == GetSystemMetrics(SM_CXSCREEN)))) // user portrait, device landscape + if( (width > GetSystemMetrics(SM_CYSCREEN)) || (height > GetSystemMetrics(SM_CXSCREEN))) +// if( !((width == gapi->gxProperties.cyHeight) && (height == gapi->gxProperties.cxWidth))) // user portrait, device landscape gapi->hiresFix = 1; switch( gapi->userOrientation ) !! It used to query system metrics which return dimensions according to screen !! orientation, which can really be portrait, left landscape or right landscape. !! This is presumably incorrect because we couldn't care less about user mode !! dimensions - all we want are the GAPI framebuffer dimensions, which only match !! user dimensions in one of possible orientations. !! There's a fair dose of cargo cult programming involved in this fix, but it !! used to work only in one orientation (portrait for PDAs, where frame-buffer !! have same orientation as user screen), and now it works on all orientations. @@ -742,21 +746,30 @@ WIN_FlushMessageQueue(); /* Open GAPI display */ - if( !gapi->useVga && this->hidden->useGXOpenDisplay ) + if( !gapi->useVga && this->hidden->useGXOpenDisplay && !this->hidden->alreadyGXOpened ) + { + this->hidden->alreadyGXOpened = 1; if( !gapi->gxFunc.GXOpenDisplay(SDL_Window, GX_FULLSCREEN) ) { SDL_SetError("Couldn't initialize GAPI"); return(NULL); } + } #if REPORT_VIDEO_INFO printf("Video properties:\n"); printf("display bpp: %d\n", gapi->gxProperties.cBPP); printf("display width: %d\n", gapi->gxProperties.cxWidth); printf("display height: %d\n", gapi->gxProperties.cyHeight); + printf("system display width: %d\n", GetSystemMetrics(SM_CXSCREEN)); + printf("system display height: %d\n", GetSystemMetrics(SM_CYSCREEN)); printf("x pitch: %d\n", gapi->gxProperties.cbxPitch); printf("y pitch: %d\n", gapi->gxProperties.cbyPitch); printf("gapi flags: 0x%x\n", gapi->gxProperties.ffFormat); + printf("user orientation: %d\n", gapi->userOrientation); + printf("system orientation: %d\n", gapi->userOrientation); + printf("gapi orientation: %d\n", gapi->gapiOrientation); + if( !gapi->useVga && this->hidden->useGXOpenDisplay && gapi->needUpdate) { !! Previous version used to call gapi->gxFunc.GXOpenDisplay each time the video !! mode would be changed. You shouldn't, because this call has a meaning "Lock the !! GAPI framebuffer, designate it as busy", so the second call will fail (it is !! already locked/busy). !! Testing might not find that because most programs set up the video mode only !! once, but POWDER does this once in a while, so it crashed when in 320x240 mode !! (640x480 mode doesn't use that code, it worked fine). diff -bru SDL-1.2.13/src/video/gapi/SDL_gapivideo.h SDL-1.2.13-new/src/video/gapi/SDL_gapivideo.h --- SDL-1.2.13/src/video/gapi/SDL_gapivideo.h 2007-12-31 07:48:00.000000000 +0300 +++ SDL-1.2.13-new/src/video/gapi/SDL_gapivideo.h 2008-10-16 20:02:11.000000000 +0400 @@ -132,12 +132,17 @@ #define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */ int SDL_nummodes[NUM_MODELISTS]; SDL_Rect **SDL_modelist[NUM_MODELISTS]; + // The orientation of the video mode user wants to get + // Probably restricted to UP and RIGHT enum SDL_ScreenOrientation userOrientation; int invert; char hiresFix; // using hires mode without defining hires resource // -------------- int useGXOpenDisplay; /* use GXOpenDispplay */ + int alreadyGXOpened; int w, h; + // The orientation of GAPI framebuffer. + // Never changes on the same device. enum SDL_ScreenOrientation gapiOrientation; void *buffer; // may be 8, 16, 24, 32 bpp @@ -153,6 +158,10 @@ int startOffset; // in bytes int useVga; int suspended; // do not pu anything into video memory + // The orientation of the system, as defined by SM_CXSCREEN and SM_CYSCREEN + // User can change it by using 'screen layout' in system options + // Restricted to UP or RIGHT + enum SDL_ScreenOrientation systemOrientation; }; !! This is a flag variable, see the previous comment !! And yet another orientation: now we have to keep three of them in mind. diff -bru SDL-1.2.13/src/video/wincommon/SDL_sysevents.c SDL-1.2.13-new/src/video/wincommon/SDL_sysevents.c --- SDL-1.2.13/src/video/wincommon/SDL_sysevents.c 2007-12-31 07:48:02.000000000 +0300 +++ SDL-1.2.13-new/src/video/wincommon/SDL_sysevents.c 2008-10-16 20:02:12.000000000 +0400 @@ -160,10 +160,22 @@ #endif */ } break; + // FIXME: Older version used just SDL_VideoSurface->(w, h) + // w and h are "clipped" while x and y are "raw", which caused + // x in former and y in latter case to be clipped in a wrong direction, + // thus offsetting the coordinate on 2 x clip pixels + // (like, 128 for 640 -> 512 clipping). + // We will now try to extract and use raw values. + // The way to do that RIGHT is do (orientation-dependent) clipping before + // doing this transform, but it's hardly possible. + + // SEE SDL_mouse.c /ClipOffset to understand these calculations. case SDL_ORIENTATION_RIGHT: if (!SDL_VideoSurface) break; - rotatedX = SDL_VideoSurface->w - *y; + rotatedX = (2 * ((SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/ + SDL_VideoSurface->format->BytesPerPixel)) + + SDL_VideoSurface->w - *y; rotatedY = *x; *x = rotatedX; *y = rotatedY; @@ -172,7 +184,8 @@ if (!SDL_VideoSurface) break; rotatedX = *y; - rotatedY = SDL_VideoSurface->h - *x; + rotatedY = (2 * (SDL_VideoSurface->offset/SDL_VideoSurface->pitch)) + + SDL_VideoSurface->h - *x; *x = rotatedX; *y = rotatedY; break; !! That's the trickest part, hence the long comment. !! GAPI would really support only 320x240 or 640x480 mode, if application !! requested the different screen size (as POWDER did, wishing 256x192), then SDL !! is going to grab the first mode that fits the requested, and pad the screen !! with black bars (as they do with wide-screen films). !! It would also get, say, 240x320 mode, and to turn it into 256x192 it would !! need to rotate mouse clicks. !! It worked, but one bug slipped through: it would receive mouse clicks !! unpadded, then rotate them, and then pad the black bars. The problem is: rotate !! is done by GAPI driver while padding is done by SDL core. SDL core doesn't know !! anything about rotating, so it would pad one of dimensions incorrectly. I understand that some of my claims (or code) might seem unbacked, but you can always grab the POWDER binary, compile your own libsdl with one or more of those fixes turned off, and see how weird it would misbehave. I can even supply you with those custom builds of libsdl if you don't want to set up the build environment for windows ce, you'll just need a PDA or a smartphone with it. I plan to take care of SDL on Windows CE as long as I maintain the POWDER port. POWDER is good for that because it: Employs both padded (with centered image, black bars) and unpadded (image occupies full screen) graphics; initializes video more than once; uses both 320x240 and 640x480 video; uses both stylus and buttons. There's still a list of unresolved issues which I'm planning to fix: 1) Arrow buttons on PDA return weird scancodes compared to PC, this caused the game to misbehave before I've fixed that. You can see it on those diagrams: http://wrar.name/upload/powder-htc.png http://wrar.name/upload/powder-pda.png 2) SDL (or underlying windows) doesn't care to rotate arrow presses when we're in a low-res GAPI mode, but it will rotate them in VGA mode (because of different screen orientations, the same arrow buttons can suddently mean different directions). Solution: we should stick to GAPI user orientation (the orientation the program supposedly wants) and rotate the keys on our own. _______________________________________________ SDL mailing list SDL@lists.libsdl.org http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
author Sam Lantinga <slouken@libsdl.org>
date Fri, 07 Nov 2008 04:15:36 +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 LOCAL_C TInt BytesPerPixel(TDisplayMode aMode)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
6 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
7 return ((TDisplayModeUtils::NumDisplayModeBitsPerPixel(aMode) - 1) >> 3) + 1;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
8 }
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
13 NONSHARABLE_CLASS(CDsaA) : public CDsa
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
14 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
15 public:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
16 CDsaA(RWsSession& aSession);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
17 private:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
18 ~CDsaA();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
19 TUint8* LockSurface();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
20 void UnlockHWSurfaceRequestComplete();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
21 void UnlockHwSurface();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
22 void CreateSurfaceL();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
23 void Wipe(TInt aLength);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
24 void RecreateL();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
25 void Free();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
26 TInt ExternalUpdate() {return 0;}
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
27 private:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
28 CFbsBitmap* iBmp;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
29 };
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
32 CDsaA::CDsaA(RWsSession& aSession) : CDsa(aSession)
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 }
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 void CDsaA::Free()
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 delete iBmp;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
39 iBmp = NULL;
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
42 CDsaA::~CDsaA()
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 __ASSERT_DEBUG(iBmp == NULL, PANIC(KErrNotReady));
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
47 TUint8* CDsaA::LockSurface()
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 iBmp->LockHeap();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
50 return reinterpret_cast<TUint8*>(iBmp->DataAddress());
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
51 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
52
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
53 void CDsaA::UnlockHWSurfaceRequestComplete()
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 PANIC(KErrNotSupported);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
56 }
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 void CDsaA::UnlockHwSurface()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
59 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
60 iBmp->UnlockHeap();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
61 SetUpdating(EFalse);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
62 Dsa().Gc()->BitBlt(HwRect().iTl, iBmp);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
63 Dsa().ScreenDevice()->Update();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
64 }
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 void CDsaA::CreateSurfaceL()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
67 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
68 delete iBmp;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
69 iBmp = NULL;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
70 iBmp = new (ELeave) CFbsBitmap();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
71 User::LeaveIfError(iBmp->Create(HwRect().Size(), DisplayMode()));
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
72 }
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 void CDsaA::Wipe(TInt aLength) //dont call in drawing
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
75 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
76 iBmp->LockHeap();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
77 Mem::FillZ(iBmp->DataAddress(), aLength);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
78 iBmp->UnlockHeap();
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 void CDsaA::RecreateL()
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 }
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 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
86
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
87 NONSHARABLE_CLASS(MDsbObs)
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 public:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
90 virtual void SurfaceReady() = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
91 virtual CDirectScreenBitmap& Dsb() = 0;
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 NONSHARABLE_CLASS(CDsbSurface) : public CActive
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 public:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
97 CDsbSurface(MDsbObs& aDsb);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
98 TUint8* Address();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
99 void Complete();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
100 ~CDsbSurface();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
101 private:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
102 void RunL();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
103 void DoCancel();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
104 private:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
105 MDsbObs& iDsb;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
106 TUint8* iAddress;
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
109 CDsbSurface::CDsbSurface(MDsbObs& aDsb) : CActive(CActive::EPriorityHigh) , iDsb(aDsb)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
110 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
111 CActiveScheduler::Add(this);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
112 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
113
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
114 CDsbSurface::~CDsbSurface()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
115 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
116 Cancel();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
117 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
118
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
119 void CDsbSurface::Complete()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
120 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
121 if(iAddress != NULL && !IsActive())
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
122 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
123 iAddress = NULL;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
124 SetActive();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
125 iDsb.Dsb().EndUpdate(iStatus);
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
129 TUint8* CDsbSurface::Address()
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 if(iAddress == NULL && !IsActive())
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 TAcceleratedBitmapInfo info;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
134 if(KErrNone == iDsb.Dsb().BeginUpdate(info))
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
135 iAddress = info.iAddress;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
136 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
137 return iAddress;
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
140 void CDsbSurface::RunL()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
141 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
142 iDsb.SurfaceReady();
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 void CDsbSurface::DoCancel()
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 //empty
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
148 }
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 NONSHARABLE_CLASS(CDsaB) : public CDsa, public MDsbObs
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
151 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
152 public:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
153 CDsaB(RWsSession& aSession);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
154 private:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
155 ~CDsaB();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
156 TUint8* LockSurface();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
157 void UnlockHWSurfaceRequestComplete();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
158 void UnlockHwSurface();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
159 void CreateSurfaceL();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
160 void Wipe(TInt aLength);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
161 void RecreateL();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
162 void ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
163 void Free();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
164 CDirectScreenBitmap& Dsb();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
165 void SurfaceReady();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
166 TInt ExternalUpdate() {return 0;}
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
167 private:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
168 CDsbSurface* iSurface1;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
169 CDsbSurface* iSurface2;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
170 CDirectScreenBitmap* iDsb;
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
173 CDsaB::CDsaB(RWsSession& aSession) : CDsa(aSession)
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 }
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 void CDsaB::Free()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
178 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
179 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
180
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
181 void CDsaB::UnlockHWSurfaceRequestComplete()
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 iSurface1->Complete();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
184 iSurface2->Complete();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
185 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
186
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
187 void CDsaB::CreateSurfaceL()
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 void CDsaB::Wipe(TInt aLength) //dont call in drawing
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
192 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
193 TUint8* addr = LockSurface();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
194 if(addr != NULL)
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 Mem::FillZ(addr, aLength);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
197 UnlockHwSurface();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
198 }
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
201 void CDsaB::UnlockHwSurface()
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 EpocSdlEnv::Request(CDsa::ERequestUpdate);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
204 }
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 TUint8* CDsaB::LockSurface()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
207 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
208 TUint8* addr = iSurface1->Address();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
209 if(addr == NULL)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
210 addr = iSurface2->Address();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
211 SetUpdating(addr == NULL);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
212 return addr;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
213 }
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 void CDsaB::SurfaceReady()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
216 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
217 SetUpdating(EFalse);
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 CDirectScreenBitmap& CDsaB::Dsb()
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 return *iDsb;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
223 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
224
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
225 void CDsaB::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
226 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
227 if(iDsb == NULL)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
228 iDsb = CDirectScreenBitmap::NewL();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
229 CDsa::ConstructL(aWindow, aDevice);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
230 iSurface1 = new (ELeave) CDsbSurface(*this);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
231 iSurface2 = new (ELeave) CDsbSurface(*this);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
232 }
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 CDsaB::~CDsaB()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
235 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
236 delete iSurface1;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
237 delete iSurface2;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
238 delete iDsb;
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
241 void CDsaB::RecreateL()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
242 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
243 iDsb->Close();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
244 iDsb->Create(HwRect(), CDirectScreenBitmap::EDoubleBuffer);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
245 }
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 /////////////////////////////////////////////////////////////////////////////////////////////////////
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
250 TSize CDsa::WindowSize() const
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
251 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
252 TSize size = HwRect().Size();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
253 if(iStateFlags & EOrientation90)
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 const TInt tmp = size.iWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
256 size.iWidth = size.iHeight;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
257 size.iHeight = tmp;
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 return size;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
260 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
261
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
262 void CDsa::SetSuspend()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
263 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
264 iStateFlags |= ESdlThreadSuspend;
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
267 void CDsa::ReleaseStop()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
268 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
269 iStateFlags &= ~ESdlThreadExplicitStop;
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
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 TBool CDsa::Stopped() const
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 return (iStateFlags & ESdlThreadExplicitStop);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
276 }
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 void CDsa::SetOrientation(CSDL::TOrientationMode aOrientation)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
279 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
280 TInt flags = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
281 switch(aOrientation)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
282 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
283 case CSDL::EOrientation90:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
284 flags = EOrientation90;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
285 break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
286 case CSDL::EOrientation180:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
287 flags = EOrientation180;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
288 break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
289 case CSDL::EOrientation270:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
290 flags = EOrientation90 | EOrientation180;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
291 break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
292 case CSDL::EOrientation0:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
293 flags = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
294 break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
295 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
296 if(flags != (iStateFlags & EOrientationFlags))
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 iStateFlags |= EOrientationChanged;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
299 iNewFlags = flags; //cannot be set during drawing...
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 CDsa::~CDsa()
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 if(iDsa != NULL)
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 iDsa->Cancel();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
308 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
309 delete iDsa;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
310 User::Free(iLut256);
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
313 void CDsa::ConstructL(RWindow& aWindow, CWsScreenDevice& aDevice)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
314 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
315 if(iDsa != NULL)
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 iDsa->Cancel();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
318 delete iDsa;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
319 iDsa = NULL;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
320 }
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
323 iDsa = CDirectScreenAccess::NewL(
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
324 iSession,
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
325 aDevice,
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
326 aWindow,
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
327 *this);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
328
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
329 if(iLut256 == NULL)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
330 iLut256 = (TUint32*) User::AllocL(256 * sizeof(TUint32));
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
331 iTargetMode = aWindow.DisplayMode();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
332 iTargetBpp = BytesPerPixel(DisplayMode());
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
333 iTargetRect = TRect(aWindow.Position(), aWindow.Size());
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
334 RestartL();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
335 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
336
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
337 void CDsa::LockPalette(TBool aLock)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
338 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
339 if(aLock)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
340 iStateFlags |= EPaletteLocked;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
341 else
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
342 iStateFlags &= ~EPaletteLocked;
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 TInt CDsa::SetPalette(TInt aFirst, TInt aCount, TUint32* aPalette)
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 if(iLut256 == NULL)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
347 return KErrNotFound;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
348 const TInt count = aCount - aFirst;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
349 if(count > 256)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
350 return KErrArgument;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
351 if(iStateFlags & EPaletteLocked)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
352 return KErrNone;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
353 for(TInt i = aFirst; i < count; i++) //not so busy here:-)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
354 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
355 iLut256[i] = aPalette[i];
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
356 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
357 return KErrNone;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
358 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
359
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
360
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 void CDsa::RestartL()
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 //const TBool active = iDsa->IsActive();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
366
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
367 //if(!active)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
368 iDsa->StartL();
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 RRegion* r = iDsa->DrawingRegion();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
371 iDsa->Gc()->SetClippingRegion(r);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
372 TRect rect = r->BoundingRect();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
373
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
374 if(rect.IsEmpty())
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 return;
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
379 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
380
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
381 RecreateL();
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 iStateFlags |= ERunning;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
384 // iScanLineWidth = iTargetBpp * HwRect().Width();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
385 ReleaseStop();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
386 if(iStateFlags & ESdlThreadSuspend)
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 EpocSdlEnv::Resume();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
389 iStateFlags &= ~ ESdlThreadSuspend;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
390 }
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
393 CDsa::CDsa(RWsSession& aSession) :
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
394 iSession(aSession),
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
395 iStateFlags(0)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
396 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
397 // CActiveScheduler::Add(this);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
398 iCFTable[0] = CopyMem;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
399 iCFTable[1] = CopyMemFlipReversed;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
400 iCFTable[2] = CopyMemReversed;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
401 iCFTable[3] = CopyMemFlip;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
402
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
403 iCFTable[4] = Copy256;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
404 iCFTable[5] = Copy256FlipReversed;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
405 iCFTable[6] = Copy256Reversed;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
406 iCFTable[7] = Copy256Flip;
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 iCFTable[8] = CopySlow;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
410 iCFTable[9] = CopySlowFlipReversed;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
411 iCFTable[10] = CopySlowReversed;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
412 iCFTable[11] = CopySlowFlip;
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
415 RWsSession& CDsa::Session()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
416 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
417 return iSession;
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
420
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
421
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
422 TUint8* CDsa::LockHwSurface()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
423 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
424 if((iStateFlags & EUpdating) == 0) //else frame is skipped
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 return LockSurface();
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 return NULL;
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 /*
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
432 void CDsa::RunL()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
433 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
434 iStateFlags &= ~EUpdating;
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
438 void CDsa::DoCancel()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
439 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
440 iStateFlags &= ~EUpdating;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
441 //nothing can do, just wait?
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
442 }
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
445 TInt CDsa::AllocSurface(TBool aHwSurface, const TSize& aSize, TDisplayMode aMode)
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 if(aHwSurface && aMode != DisplayMode())
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
448 return KErrArgument;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
449
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
450 iSourceMode = aMode;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
451
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
452 iSourceBpp = BytesPerPixel(aMode);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
453
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
454 const TSize size = WindowSize();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
455 if(aSize.iWidth > size.iWidth)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
456 return KErrTooBig;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
457 if(aSize.iHeight > size.iHeight)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
458 return KErrTooBig;
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 TRAPD(err, CreateSurfaceL());
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
461 if(err != KErrNone)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
462 return err;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
463
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 SetCopyFunction();
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 EpocSdlEnv::ObserverEvent(MSDLObserver::EEventWindowReserved);
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 return KErrNone;
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
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 /*
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
474 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
475 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
476 CFbsBitmap* s = new CFbsBitmap();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
477 s->Create(aSz, aMode);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
478 s->LockHeap();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
479 TUint32* addr = s->DataAddress();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
480 Mem::Copy(addr, aData, aLength);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
481 s->UnlockHeap();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
482 s->Save(aName);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
483 s->Reset();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
484 delete s;
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 void SaveBmp(const TDesC& aName, const TUint32* aData, const TSize& aSz)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
488 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
489 CFbsBitmap* s = new CFbsBitmap();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
490 s->Create(aSz, EColor64K);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
491 TBitmapUtil bmp(s);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
492 bmp.Begin(TPoint(0, 0));
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
493 for(TInt j = 0; j < aSz.iHeight; j++)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
494 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
495 bmp.SetPos(TPoint(0, j));
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
496 for(TInt i = 0; i < aSz.iWidth; i++)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
497 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
498 bmp.SetPixel(*aData);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
499 aData++;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
500 bmp.IncXPos();
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 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
503 bmp.End();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
504 s->Save(aName);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
505 s->Reset();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
506 delete s;
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 TBuf<16> FooName(TInt aFoo)
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 TBuf<16> b;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
512 b.Format(_L("C:\\pic%d.mbm"), aFoo);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
513 return b;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
514 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
515 */
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
516 void CDsa::ClipCopy(TUint8* aTarget, const TUint8* aSource, const TRect& aRect, const TRect& aTargetPos) const
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 TUint8* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
519 const TUint8* source = aSource;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
520 const TInt lineWidth = aRect.Width();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
521 source += iSourceBpp * (aRect.iTl.iY * lineWidth);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
522 TInt sourceStartOffset = iSourceBpp * aRect.iTl.iX;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
523 source += sourceStartOffset;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
524 target += iTargetBpp * ((aTargetPos.iTl.iY + aRect.iTl.iY ) * lineWidth);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
525 TInt targetStartOffset = iTargetBpp * (aRect.iTl.iX + aTargetPos.iTl.iX);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
526 target += targetStartOffset;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
527 TUint32* targetPtr = reinterpret_cast<TUint32*>(target);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
528 const TInt targetWidth = HwRect().Size().iWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
529 const TInt height = aRect.Height();
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 TInt lineMove = iStateFlags & EOrientation90 ? 1 : lineWidth;
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(iStateFlags & EOrientation180)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
534 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
535
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
536 targetPtr += targetWidth * (height - 1);
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 for(TInt i = 0; i < height; i++) //source is always smaller
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 iCopyFunction(*this, targetPtr, source, lineWidth, height);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
541 source += lineMove;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
542 targetPtr -= targetWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
543 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
544 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
545 else
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
546 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
547
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 for(TInt i = 0; i < height; i++) //source is always smaller
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 iCopyFunction(*this, targetPtr, source, lineWidth, height);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
552 source += lineMove;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
553 targetPtr += targetWidth;
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
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
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
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 void CDsa::Wipe() //dont call in drawing
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 if(IsDsaAvailable())
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
565 Wipe(iTargetBpp * iScreenRect.Width() * iScreenRect.Height());
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
566 }
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 void CDsa::SetCopyFunction()
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 //calculate offset to correct function in iCFTable according to given parameters
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
571 TInt function = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
572 const TInt KCopyFunctions = 4;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
573 const TInt KOffsetToNative = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
574 const TInt KOffsetTo256 = KOffsetToNative + KCopyFunctions;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
575 const TInt KOffsetToOtherModes = KOffsetTo256 + KCopyFunctions;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
576 const TInt KOffsetTo90Functions = 1;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
577 const TInt KOffsetTo180Functions = 2;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
578
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
579 if(iSourceMode == DisplayMode())
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
580 function = KOffsetToNative; //0
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
581 else if(iSourceMode == EColor256)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
582 function = KOffsetTo256; //4
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
583 else
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
584 function = KOffsetToOtherModes; //8
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 if(iStateFlags & EOrientation90)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
587 function += KOffsetTo90Functions; // + 1
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
588 if(iStateFlags & EOrientation180)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
589 function += KOffsetTo180Functions; //+ 2
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 iCopyFunction = iCFTable[function];
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
592
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
593 Wipe();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
594 }
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 inline void Rotate(TRect& aRect)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
597 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
598 const TInt dx = aRect.iBr.iX - aRect.iTl.iX;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
599 const TInt dy = aRect.iBr.iY - aRect.iTl.iY;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
600
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
601 aRect.iBr.iX = aRect.iTl.iX + dy;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
602 aRect.iBr.iY = aRect.iTl.iY + dx;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
603
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
604 const TInt tmp = aRect.iTl.iX;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
605 aRect.iTl.iX = aRect.iTl.iY;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
606 aRect.iTl.iY = tmp;
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
609 /*
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
610 int bar = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
611 */
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
612 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
613 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
614
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
615 if(iStateFlags & EOrientationChanged)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
616 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
617 iStateFlags &= ~EOrientationFlags;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
618 iStateFlags |= iNewFlags;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
619 SetCopyFunction();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
620 iStateFlags &= ~EOrientationChanged;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
621 EpocSdlEnv::WaitDeviceChange();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
622 return EFalse; //skip this frame as data is may be changed
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
623 }
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 if(iTargetAddr == NULL)
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 iTargetAddr = LockHwSurface();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
628 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
629 TUint8* target = iTargetAddr;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
630 if(target == NULL)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
631 return EFalse;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
632
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 TRect targetRect = HwRect();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
635 TRect sourceRect = aRect;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
636 TRect updateRect = aUpdateRect;
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 if(iStateFlags & EOrientation90)
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 Rotate(sourceRect);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
641 Rotate(updateRect);
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 if(iSourceMode != DisplayMode() || targetRect != sourceRect || targetRect != updateRect || ((iStateFlags & EOrientationFlags) != 0))
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 sourceRect.Intersection(targetRect); //so source always smaller or equal than target
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
647 updateRect.Intersection(targetRect);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
648 ClipCopy(target, aBits, updateRect, sourceRect);
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 else
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 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
653 Mem::Copy(target, aBits, byteCount);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
654 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
655
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
656 return ETrue;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
657 }
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 CDsa* CDsa::CreateL(RWsSession& aSession)
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 if(EpocSdlEnv::Flags(CSDL::EDrawModeDSB))
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
662 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
663 TInt flags = CDirectScreenBitmap::ENone;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
664 if(EpocSdlEnv::Flags(CSDL::EDrawModeDSBDoubleBuffer))
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
665 flags |= CDirectScreenBitmap::EDoubleBuffer;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
666 if(EpocSdlEnv::Flags(CSDL::EDrawModeDSBIncrentalUpdate))
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
667 flags |= CDirectScreenBitmap::EIncrementalUpdate;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
668 return new (ELeave) CDsaB(aSession);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
669 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
670 else
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
671 return new (ELeave) CDsaA(aSession);
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
674 void CDsa::CreateZoomerL(const TSize& aSize)
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 iSwSize = aSize;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
677 iStateFlags |= EResizeRequest;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
678 CreateSurfaceL();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
679 SetTargetRect();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
680 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
681
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
682 TPoint CDsa::WindowCoordinates(const TPoint& aPoint) const
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 TPoint pos = aPoint - iScreenRect.iTl;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
685 const TSize asz = iScreenRect.Size();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
686 if(iStateFlags & EOrientation180)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
687 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
688 pos.iX = asz.iWidth - pos.iX;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
689 pos.iY = asz.iHeight - pos.iY;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
690 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
691 if(iStateFlags & EOrientation90)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
692 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
693 pos.iX = aPoint.iY;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
694 pos.iY = aPoint.iX;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
695 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
696 pos.iX <<= 16;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
697 pos.iY <<= 16;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
698 pos.iX /= asz.iWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
699 pos.iY /= asz.iHeight;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
700 pos.iX *= iSwSize.iWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
701 pos.iY *= iSwSize.iHeight;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
702 pos.iX >>= 16;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
703 pos.iY >>= 16;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
704 return pos;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
705 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
706
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
707 void CDsa::SetTargetRect()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
708 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
709 iTargetRect = iScreenRect;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
710 if(iStateFlags & EResizeRequest && EpocSdlEnv::Flags(CSDL::EAllowImageResizeKeepRatio))
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
711 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
712 const TSize asz = iScreenRect.Size();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
713 const TSize sz = iSwSize;
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 TRect rect;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
716
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
717 const TInt dh = (sz.iHeight << 16) / sz.iWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
718
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
719 if((asz.iWidth * dh ) >> 16 <= asz.iHeight)
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 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
722 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
723 else
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
724 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
725 const TInt dw = (sz.iWidth << 16) / sz.iHeight;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
726 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
727 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
728 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
729
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
730 iTargetRect = rect;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
731 iTargetRect.Move(iScreenRect.iTl);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
732
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
733 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
734 if(!(iStateFlags & EResizeRequest))
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
735 iSwSize = iScreenRect.Size();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
736 // iScanLineWidth = /*iTargetBpp **/ SwSize().iWidth;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
737 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
738
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
739 void CDsa::RecreateL()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
740 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
741 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
742
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
743 void CDsa::Free()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
744 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
745 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
746
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
747 void CDsa::UpdateSwSurface()
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 iTargetAddr = NULL;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
750 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
751 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
752
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
753 void CDsa::SetBlitter(MBlitter* aBlitter)
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 iBlitter = aBlitter;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
756 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
757
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
758 void CDsa::DrawOverlays()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
759 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
760 const TInt last = iOverlays.Count() - 1;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
761 for(TInt i = last; i >= 0 ; i--)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
762 iOverlays[i].iOverlay->Draw(*iDsa->Gc(), HwRect(), SwSize());
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
763 }
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 TInt CDsa::AppendOverlay(MOverlay& aOverlay, TInt aPriority)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
766 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
767 TInt i;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
768 for(i = 0; i < iOverlays.Count() && iOverlays[i].iPriority < aPriority; i++)
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 const TOverlay overlay = {&aOverlay, aPriority};
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
771 return iOverlays.Insert(overlay, i);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
772 }
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 TInt CDsa::RemoveOverlay(MOverlay& aOverlay)
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 for(TInt i = 0; i < iOverlays.Count(); i++)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
777 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
778 if(iOverlays[i].iOverlay == &aOverlay)
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 iOverlays.Remove(i);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
781 return KErrNone;
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 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
784 return KErrNotFound;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
785 }
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 TInt CDsa::RedrawRequest()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
788 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
789 if(!(iStateFlags & (EUpdating) && (iStateFlags & ERunning)))
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 return ExternalUpdate();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
792 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
793 return KErrNotReady;
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
797 void CDsa::Resume()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
798 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
799 if(Stopped())
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
800 Restart(RDirectScreenAccess::ETerminateRegion);
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 void CDsa::DoStop()
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 if(IsDsaAvailable())
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
806 iStateFlags |= ESdlThreadExplicitStop;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
807 Stop();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
808 }
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 void CDsa::Stop()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
811 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
812 iStateFlags &= ~ERunning;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
813 // Cancel(); //can be called only from main!
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
814 iDsa->Cancel();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
815 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
816
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
817 void CDsa::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
818 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
819 // iStateFlags |= EChangeNotify;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
820 Stop();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
821 }
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 void CDsa::Restart(RDirectScreenAccess::TTerminationReasons aReason)
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(aReason == RDirectScreenAccess::ETerminateRegion) //auto restart
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 TRAPD(err, RestartL());
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
828 PANIC_IF_ERROR(err);
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 }
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 TBool CDsa::ChangeTrigger()
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
833 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
834 const TBool change = iStateFlags & EChangeNotify;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
835 iStateFlags &= ~EChangeNotify;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
836 return change;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
837 }
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 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
842 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
843 TUint32* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
844 const TUint32* endt = target + aBytes;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
845 const TUint8* source = aSource;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
846 while(target < endt)
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 *target++ = aDsa.iLut256[*source++];
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 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
853 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
854 const TUint32* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
855 TUint32* endt = aTarget + aBytes;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
856 const TUint8* source = aSource;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
857 while(target < endt)
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 *(--endt) = aDsa.iLut256[*source++];
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
860 }
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
863 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
864 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
865 TUint32* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
866 const TUint32* endt = target + aBytes;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
867 const TUint8* column = aSource;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
868
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
869 while(target < endt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
870 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
871 *target++ = aDsa.iLut256[*column];
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
872 column += aLineLen;
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 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
877 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
878 const TUint32* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
879 TUint32* endt = aTarget + aBytes;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
880 const TUint8* column = aSource;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
881
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
882 while(target < endt)
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 *(--endt) = aDsa.iLut256[*column];
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
885 column += aLineLen;
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 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
888
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
889 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
890 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
891 Mem::Copy(aTarget, aSource, aBytes);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
892 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
893
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
894 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
895 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
896 TUint32* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
897 const TUint32* endt = target + aBytes;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
898 const TUint32* column = reinterpret_cast<const TUint32*>(aSource);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
899
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
900 while(target < endt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
901 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
902 *target++ = *column;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
903 column += aLineLen;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
904 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
905 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
906
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
907 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
908 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
909 const TUint32* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
910 TUint32* endt = aTarget + aBytes;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
911 const TUint32* source = reinterpret_cast<const TUint32*>(aSource);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
912 while(target < endt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
913 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
914 *(--endt) = *source++;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
915 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
916 }
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
919 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
920 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
921 const TUint32* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
922 TUint32* endt = aTarget + aBytes;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
923 const TUint32* column = reinterpret_cast<const TUint32*>(aSource);
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 while(target < endt)
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 *(--endt) = *column;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
928 column += aLineLen;
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 }
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 typedef TRgb (*TRgbFunc) (TInt aValue);
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 LOCAL_C TRgb rgb16MA(TInt aValue)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
936 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
937 return TRgb::Color16MA(aValue);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
938 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
939
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
940 NONSHARABLE_CLASS(MRgbCopy)
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 public:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
943 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
944 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
945 };
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
946 template <class T>
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
947 NONSHARABLE_CLASS(TRgbCopy) : public MRgbCopy
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
948 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
949 public:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
950 TRgbCopy(TDisplayMode aMode);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
951 void* operator new(TUint aBytes, TAny* aMem);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
952 void Copy(TUint32* aTarget, const TUint8* aSource, TInt aBytes, TBool aReversed);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
953 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
954 private:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
955 TRgbFunc iFunc;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
956 };
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 template <class T>
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
959 void* TRgbCopy<T>::operator new(TUint /*aBytes*/, TAny* aMem)
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 return aMem;
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
964 template <class T>
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
965 TRgbCopy<T>::TRgbCopy(TDisplayMode aMode)
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 switch(aMode)
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 case EGray256 : iFunc = TRgb::Gray256; break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
970 case EColor256 : iFunc = TRgb::Color256; break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
971 case EColor4K : iFunc = TRgb::Color4K; break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
972 case EColor64K : iFunc = TRgb::Color64K; break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
973 case EColor16M : iFunc = TRgb::Color16M; break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
974 case EColor16MU : iFunc = TRgb::Color16MU; break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
975 case EColor16MA : iFunc = rgb16MA; break;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
976 default:
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
977 PANIC(KErrNotSupported);
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 }
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 template <class T>
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
982 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
983 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
984 const T* source = reinterpret_cast<const T*>(aSource);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
985 TUint32* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
986 TUint32* endt = target + aBytes;
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 if(aReversed)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
989 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
990 while(target < endt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
991 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
992 TUint32 value = *source++;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
993 *(--endt) = iFunc(value).Value();
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 else
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 while(target < endt)
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 TUint32 value = *source++;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1001 *target++ = iFunc(value).Value();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1002 }
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1006 template <class T>
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1007 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
1008 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1009 const T* column = reinterpret_cast<const T*>(aSource);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1010 TUint32* target = aTarget;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1011 TUint32* endt = target + aBytes;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1012
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1013 if(aReversed)
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 while(target < endt)
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 *(--endt) = iFunc(*column).Value();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1018 column += aLineLen;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1019 }
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 while(target < endt)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1024 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1025 *target++ = iFunc(*column).Value();
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1026 column += aLineLen;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1027 }
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 }
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1032 typedef TUint64 TStackMem;
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 LOCAL_C MRgbCopy* GetCopy(TAny* mem, TDisplayMode aMode)
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 if(aMode == EColor256 || aMode == EGray256)
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 return new (mem) TRgbCopy<TUint8>(aMode);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1039 }
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1040 if(aMode == EColor4K || aMode == EColor64K)
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 return new (mem) TRgbCopy<TUint16>(aMode);
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(aMode == EColor16M || aMode == EColor16MU || aMode == EColor16MA)
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1045 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1046 return new (mem) TRgbCopy<TUint32>(aMode);
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 PANIC(KErrNotSupported);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1049 return NULL;
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1052
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1053 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
1054 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1055 TStackMem mem = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1056 GetCopy(&mem, aDsa.iSourceMode)->FlipCopy(aTarget, aSource, aBytes, aLineLen, ETrue);
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1059 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
1060 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1061 TStackMem mem = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1062 GetCopy(&mem, aDsa.iSourceMode)->FlipCopy(aTarget, aSource, aBytes, aLineLen, EFalse);
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
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1065 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
1066 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1067 TStackMem mem = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1068 GetCopy(&mem, aDsa.iSourceMode)->Copy(aTarget, aSource, aBytes, EFalse);
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::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
1072 {
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1073 TStackMem mem = 0;
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1074 GetCopy(&mem, aDsa.iSourceMode)->Copy(aTarget, aSource, aBytes, ETrue);
e85e65aec22f Added S60 port.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1075 }