Usermode/AxWin3 - Fixed bad blit clipping
authorJohn Hodge (sonata) <[email protected]>
Wed, 28 Nov 2012 07:28:09 +0000 (15:28 +0800)
committerJohn Hodge (sonata) <[email protected]>
Wed, 28 Nov 2012 07:28:09 +0000 (15:28 +0800)
Usermode/Applications/axwin3_src/WM/video.c
Usermode/Applications/axwin3_src/WM/wm.c

index 3916baa..d400568 100644 (file)
@@ -132,29 +132,34 @@ void Video_FillRect(int X, int Y, int W, int H, uint32_t Colour)
 void Video_Blit(uint32_t *Source, short DstX, short DstY, short W, short H)
 {
        uint32_t        *buf;
+       short   drawW = W;
 
        if( DstX >= giScreenWidth)      return ;
        if( DstY >= giScreenHeight)     return ;
        // TODO: Handle -ve X/Y by clipping
        if( DstX < 0 || DstY < 0 )      return ;
        // TODO: Handle out of bounds by clipping too
-       if( DstX + W > giScreenWidth )  return;
+       if( DstX + drawW > giScreenWidth ) {
+               int oldw = drawW;
+               drawW = giScreenWidth - DstX;
+               _SysDebug("Video_Blit: Clipped width from %i to %i", oldw, drawW);
+       }
        if( DstY + H > giScreenHeight )
                H = giScreenHeight - DstY;
 
        if( W <= 0 || H <= 0 )  return;
 
-       if( DstX < giVideo_FirstDirtyLine )
+       if( DstY < giVideo_FirstDirtyLine )
                giVideo_FirstDirtyLine = DstY;
        if( DstY + H > giVideo_LastDirtyLine )
                giVideo_LastDirtyLine = DstY + H;
        
        buf = gpScreenBuffer + DstY*giScreenWidth + DstX;
-       if(W != giScreenWidth)
+       if(drawW != giScreenWidth)
        {
                while( H -- )
                {
-                       memcpy(buf, Source, W*4);
+                       memcpy(buf, Source, drawW*4);
                        Source += W;
                        buf += giScreenWidth;
                }
index 464eeb1..89cdd06 100644 (file)
@@ -142,6 +142,31 @@ void WM_RaiseWindow(tWindow *Window)
        parent->LastChild = Window;
 }
 
+/*
+void WM_RaiseWindow(tWindow *Window)
+{
+       // Move to the last render position (move to top)
+       while(Window && Window->Parent)
+       {
+               if( Window->NextSibling )
+               {
+                       // remove
+                       if( Window->PrevSibling )
+                               Window->PrevSibling->NextSibling = Window->NextSibling;
+                       Window->NextSibling->PrevSibling = Window->PrevSibling;
+                       // Mutate self
+                       Window->PrevSibling = Window->Parent->LastChild;
+                       Window->NextSibling = NULL;
+                       // re-add
+                       Window->PrevSibling->NextSibling = Window;
+                       Window->Parent->LastChild = Window;
+               }
+               _SysDebug("WM_RaiseWindow: Raised %p", Window);
+               Window = Window->Parent;
+       }
+}
+*/
+
 void WM_FocusWindow(tWindow *Destination)
 {
        struct sWndMsg_Bool     _msg;
@@ -164,12 +189,10 @@ void WM_FocusWindow(tWindow *Destination)
                
        WM_Invalidate(gpWM_FocusedWindow);
        WM_Invalidate(Destination);
-       gpWM_FocusedWindow = Destination;
 
+       WM_RaiseWindow(Destination);    
 
-       // Get the owner of the focused window  
-//     while(Destination && Destination->Owner)        Destination = Destination->Owner;
-//     gpWM_HilightedWindow = Destination;
+       gpWM_FocusedWindow = Destination;
 }
 
 
@@ -263,6 +286,7 @@ int WM_MoveWindow(tWindow *Window, int X, int Y)
        }
        // TODO: Re-sanitise
 
+       _SysDebug("WM_MoveWindow: (%i,%i)", X, Y);
        Window->X = X;  Window->Y = Y;
 
        // TODO: Why invalidate buffer?
@@ -280,6 +304,7 @@ int WM_ResizeWindow(tWindow *Window, int W, int H)
        if( Window->W == W && Window->H == H )
                return 0;
 
+       _SysDebug("WM_Resizeindow: %ix%i", W, H);
        Window->W = W;  Window->H = H;
 
        if(Window->RenderBuffer) {

UCC git Repository :: git.ucc.asn.au