hwblt.cpp

来自「6410BSP3」· C++ 代码 · 共 1,133 行 · 第 1/4 页

CPP
1,133
字号
                iRotate = DMDO_0;
                break;
            case DMDO_270:
                iRotate = DMDO_90;
                break;
            }

            /// Set Destination Surface to real Framebuffer Surface
            m_oG2D->SetDstSurface(pdescDstSurface);
            /// Set Destination Clipping window Rect
            if(pBltParms->prclClip)
            {
                m_oG2D->SetClipWindow(pBltParms->prclClip);
            }
            else
            {
                m_oG2D->SetClipWindow(prclDst);
            }

            /// SWAP rect
            SWAP(prclDst->top, prclDst->bottom, LONG);
            SWAP(prclDst->left, prclDst->right, LONG);

            EnterCriticalSection(&m_cs2D);
            m_oG2D->BitBlt( prclSrc, prclDst, m_oG2D->GetRotType(iRotate));
            LeaveCriticalSection(&m_cs2D);
            /// Recover rect
            SWAP(prclDst->top, prclDst->bottom, LONG);
            SWAP(prclDst->left, prclDst->right, LONG);

            RETAILMSG(DISP_ZONE_TEMP,(TEXT("XY Flip R:%d\n"), iRotate));

            return TRUE;
        }
        //RotateRectl(prclDst);
        //RotateRectlBack(prclDst);

        /// Mirroring is needed.
        if( ((pBltParms->bltFlags & BLT_STRETCH) == BLT_STRETCH) 
            &&  ((prclDst->left > prclDst->right) || (prclDst->top > prclDst->bottom) )
            )
        {
            RotateRectl(prclDst);

            RECTL   t_rect;
            DWORD   dwSrcWidth;
            DWORD   dwSrcHeight;
            SURFACE_DESCRIPTOR descScratch;

            dwSrcWidth = ABS(prclSrc->right - prclSrc->left);
            dwSrcHeight  = ABS(prclSrc->bottom - prclSrc->top);

            /// Set Scratch Destination Region
            t_rect.left = 0;
            t_rect.top = 0;
            t_rect.right = dwSrcWidth;
            t_rect.bottom = dwSrcHeight;

            RETAILMSG(DISP_ZONE_TEMP,(TEXT("t_rect,justbitbltflip(%d,%d)~(%d,%d), R:%d\r\n"), 
                t_rect.left,t_rect.top,t_rect.right,t_rect.bottom,iRotate));
            DumpBltParms(pBltParms);

            /// In mirror case, source region does not change.
            /// only destination's regions has reverse coordinate, this cannot be negative.

            /// This is Difference between source and destination.
            if(iRotate == DMDO_0)   
            {
                //  RotateRectlBack(prclDst);
                if(prclDst->right < prclDst->left)
                {
                //  RotateRectl(prclDst);
                    RETAILMSG(DISP_ZONE_TEMP, (TEXT("BitBlt Y-axis flip: R:%d\r\n"),pBltParms->pDst->Rotate()));
                    /// Set Destination Surface to real Framebuffer Surface
                    m_oG2D->SetDstSurface(pdescDstSurface);

                    RETAILMSG(DISP_ZONE_TEMP,(TEXT("BY TBSWAP:%d,%d,%d,%d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom, iRotate));
                    /// Y-axis mirror case. left-right inversion
                    /// Swap left, right coordinate
                    SWAP(prclDst->right, prclDst->left, LONG);

                    RETAILMSG(DISP_ZONE_TEMP,(TEXT("BY TASWAP:%d,%d,%d,%d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom, iRotate));
                    /// Set Destination Clipping window Rect
                    if(pBltParms->prclClip)
                    {
                        m_oG2D->SetClipWindow(pBltParms->prclClip);
                    }
                    else
                    {
                        m_oG2D->SetClipWindow(prclDst);
                    }

                    /// Set Y-axis flip flag
                    EnterCriticalSection(&m_cs2D);
                    m_oG2D->FlipBlt( prclSrc, prclDst,  FLIP_Y );
                    LeaveCriticalSection(&m_cs2D);
                    /// recover left, right coordinate
                    SWAP(prclDst->right, prclDst->left, LONG);

                    return TRUE;
                }
                else if(prclDst->bottom < prclDst->top)
                {
                    //  RotateRectl(prclDst);
                    RETAILMSG(DISP_ZONE_TEMP, (TEXT("BitBlt X-axis flip: R:%d\r\n"),pBltParms->pDst->Rotate()));
                    /// Set Destination Surface to real Framebuffer Surface
                    m_oG2D->SetDstSurface(pdescDstSurface);

                    RETAILMSG(DISP_ZONE_TEMP,(TEXT("BX TBSWAP:%d,%d,%d,%d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom, iRotate));
                    /// X-axis mirror case. up-down inversion
                    /// Swap top, bottom coordinate
                    SWAP(prclDst->top, prclDst->bottom, LONG);
                    RETAILMSG(DISP_ZONE_TEMP,(TEXT("BX TASWAP:%d,%d,%d,%d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom, iRotate));
                    /// Set Destination Clipping window Rect
                    if(pBltParms->prclClip)
                    {
                        m_oG2D->SetClipWindow(pBltParms->prclClip);
                    }
                    else
                    {
                        m_oG2D->SetClipWindow(prclDst);
                    }

                    /// Set X-axis flip flag
                    EnterCriticalSection(&m_cs2D);
                    m_oG2D->FlipBlt( prclSrc, prclDst,  FLIP_X );
                    LeaveCriticalSection(&m_cs2D);
                    /// recover top, bottom coordinate
                    SWAP(prclDst->top, prclDst->bottom, LONG);

                    return TRUE;
                   }
                //  RotateRectl(prclDst);
            }
            else if(iRotate == DMDO_90 || iRotate == DMDO_270)
            {
                RotateRectlBack(prclDst);
                /// Original Coordinate
                RETAILMSG(DISP_ZONE_TEMP, (TEXT("R:%d, DR:%d, DST(%d,%d,%d,%d)\r\n"),pBltParms->pDst->Rotate(), iRotate, 
                    pBltParms->prclDst->left,
                    pBltParms->prclDst->top,
                    pBltParms->prclDst->right,
                    pBltParms->prclDst->bottom));
                /// if screen rotation is not DMDO_0. we need to bitblt once more. and use scratch memory
                if(prclDst->right < prclDst->left)
                {
                    RotateRectl(prclDst);
                    /// Screen rotated 
                    /// if 90, 270 degree, that is T,B Swaped and rotate 
                    ///  +-----+ (L,T)
                    ///  |     |
                    ///  |     |       
                    ///  |     |
                    ///  +-----+
                    /// (R,B)

                    /// Allocation Scratch Framebuffer for Flip Operation.
                    DDGPESurf *ScratchSurf;

                    AllocSurface(&ScratchSurf, dwSrcWidth, dwSrcHeight, pBltParms->pDst->Format(), EGPEFormatToEDDGPEPixelFormat[pBltParms->pDst->Format()], GPE_REQUIRE_VIDEO_MEMORY);
                    if(ScratchSurf == NULL)
                    {
                        RETAILMSG(DISP_ZONE_WARNING,(TEXT("Scratch Surface Allocation is failed. %d\n"), __LINE__));
#if 0//USE_PACSURF, To increase video memory is better than to use system memory as Video Surface
                        RETAILMSG(TRUE,(TEXT("try to allocate surface usign PA Surface\r\n")));
                        PACSurf *ScratchSurf;
#endif
                        RETAILMSG(DISP_ZONE_WARNING,(TEXT("Maybe There's no sufficient video memory. please increase video memory\r\n")));
                        RETAILMSG(DISP_ZONE_WARNING,(TEXT("try to redirect to SW Emulated Bitblt\r\n")));
                        return FALSE;
                    }

                    /// Set Scratch Surface Information
                    descScratch.dwBaseaddr = (m_VideoMemoryPhysicalBase + ScratchSurf->OffsetInVideoMemory());
                    descScratch.dwColorMode = GetHWColorFormat(pBltParms->pDst);
                    descScratch.dwHoriRes = dwSrcWidth;
                    descScratch.dwVertRes = dwSrcHeight;

                    /// Set Destination Surface as Scratch Surface
                    m_oG2D->SetDstSurface(&descScratch);
                    /// Set Destination Clipping window Rect
                    m_oG2D->SetClipWindow(&t_rect);

                    /// Y-axis mirror case. left-right inversion

                    EnterCriticalSection(&m_cs2D);
                    m_oG2D->FlipBlt( prclSrc, &t_rect,  FLIP_Y );
                    LeaveCriticalSection(&m_cs2D);

                    /// Set Source Address to Scratch Memory
                    m_oG2D->SetSrcSurface(&descScratch);
                    /// Set Destination Surface to real Framebuffer Surface
                    m_oG2D->SetDstSurface(pdescDstSurface);

                    /// Swap left, right coordinate
                    /// Y-axis mirror case. left-right inversion
                    RETAILMSG(DISP_ZONE_TEMP,(TEXT("B TBSWAP:%d,%d,%d,%d,%d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom, iRotate, m_oG2D->GetRotType(iRotate)));
                    SWAP(prclDst->top, prclDst->bottom, LONG);
                    /// Set Destination Clipping window Rect
                    if(pBltParms->prclClip)
                    {
                        m_oG2D->SetClipWindow(pBltParms->prclClip);
                    }
                    else
                    {
                        m_oG2D->SetClipWindow(prclDst);
                    }

                    /// Set Y-axis flip flag
                    EnterCriticalSection(&m_cs2D);
                    m_oG2D->BitBlt( &t_rect, prclDst,  m_oG2D->GetRotType(iRotate) );
                    LeaveCriticalSection(&m_cs2D);
                    /// recover left, right coordinate
                    SWAP(prclDst->top, prclDst->bottom, LONG);

                    /// Disallocate Scratch Surface
                    delete ScratchSurf;

                    RETAILMSG(DISP_ZONE_TEMP, (TEXT("BitBlt Y-axis flip: R:%d\r\n"),pBltParms->pDst->Rotate()));

                    //  RotateRectl(prclDst);

                    return TRUE;

                }
                else if(prclDst->bottom < prclDst->top)
                {
                    RotateRectl(prclDst);
                    /// Allocation Scratch Framebuffer for Flip Operation.
                    DDGPESurf *ScratchSurf;

                    AllocSurface(&ScratchSurf, dwSrcWidth, dwSrcHeight, pBltParms->pDst->Format(), EGPEFormatToEDDGPEPixelFormat[pBltParms->pDst->Format()], GPE_REQUIRE_VIDEO_MEMORY);
                    if(ScratchSurf == NULL)
                    {
                        RETAILMSG(DISP_ZONE_WARNING,(TEXT("Scratch Surface Allocation is failed. %d\n"), __LINE__));
#if 0//USE_PACSURF, To increase video memory is better than to use system memory as Video Surface
                        RETAILMSG(TRUE,(TEXT("try to allocate surface usign PA Surface\r\n")));
                        PACSurf *ScratchSurf;
#endif
                        RETAILMSG(DISP_ZONE_WARNING,(TEXT("Maybe There's no sufficient video memory. please increase video memory\r\n")));
                        RETAILMSG(DISP_ZONE_WARNING,(TEXT("try to redirect to SW Emulated Bitblt\r\n")));
                        return FALSE;
                    }

                    /// Set Scratch Surface Information
                    descScratch.dwBaseaddr = (m_VideoMemoryPhysicalBase + ScratchSurf->OffsetInVideoMemory());
                    descScratch.dwColorMode = GetHWColorFormat(pBltParms->pDst);
                    descScratch.dwHoriRes = dwSrcWidth;
                    descScratch.dwVertRes = dwSrcHeight;

                    /// Set Destination Surface to Scratch Surface
                    m_oG2D->SetDstSurface(&descScratch);
                    /// Set Destination Clipping window Rect
                    m_oG2D->SetClipWindow(&t_rect);

                    /// X-axis mirror case. top-bottom inversion
                    RETAILMSG(DISP_ZONE_TEMP,(TEXT("B LRSWAP:%d,%d,%d,%d,%d,%d\n"),pBltParms->prclDst->left,pBltParms->prclDst->top,pBltParms->prclDst->right,pBltParms->prclDst->bottom, iRotate, m_oG2D->GetRotType(iRotate)));
                    EnterCriticalSection(&m_cs2D);
                    m_oG2D->FlipBlt( prclSrc, &t_rect,  FLIP_X );
                    LeaveCriticalSection(&m_cs2D);

                    /// Set Source Address to Scratch Memory
                    m_oG2D->SetSrcSurface(&descScratch);
                    /// Set Destination Surface to real Framebuffer Surface
                    m_oG2D->SetDstSurface(pdescDstSurface);

                    /// Swap left, right coordinate    
                    /// LT <-> RB
                    SWAP(prclDst->left, prclDst->right, LONG);
                    /// Set Destination Clipping window Rect
                    if(pBltParms->prclClip)
                    {
                        m_oG2D->SetClipWindow(pBltParms->prclClip);
                    }
                    else
                    {
                        m_oG2D->SetClipWindow(prclDst);
                    }

                    /// Set Y-axis flip flag
                    EnterCriticalSection(&m_cs2D);
                    m_oG2D->BitBlt( &t_rect, prclDst,  m_oG2D->GetRotType(iRotate) );
                    LeaveCriticalSection(&m_cs2D);
                    /// recover left, right coordinate

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?