⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unixroot.cpp

📁 著名的 helix realplayer 基于手机 symbian 系统的 播放器全套源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
                             0);
   if( nResult )
   {
      m_pYUVScratchBits  = new UCHAR[m_bmiYUVScratch.bmiHeader.biSizeImage];
      m_nYUVScratchPitch = GetBitmapPitch(&m_bmiYUVScratch);
   }
}


void CUnixRootSurf::_GetYUVScratchSurfacePointer(UCHAR** pYUVBits, INT32* YUVPitch)
{
   *pYUVBits = m_pYUVScratchBits;
   *YUVPitch = m_nYUVScratchPitch;
}

HX_RESULT CUnixRootSurf::CreateScratchSurface( int nCompositionSurfaceCID, HXxSize* pSize)
{
   //Remove old bits....
   HX_DELETE(m_pScratchBits);
   
   //Clear BitmapInfo struct....
   memset(&m_bmiScratch, 0, sizeof(HXBitmapInfo));
   int nResult = MakeBitmap( &m_bmiScratch,
                             sizeof(m_bmiScratch),
                             nCompositionSurfaceCID,
                             pSize->cx,
                             pSize->cy,
                             NULL,
                             0);
   if( nResult )
   {
      m_pScratchBits  = new UCHAR[m_bmiScratch.bmiHeader.biSizeImage];
      m_nScratchPitch = GetBitmapPitch(&m_bmiScratch);
   }

   return nResult? HXR_OK : HXR_FAIL;
}

HX_RESULT CUnixRootSurf::ScratchLock(UCHAR** pBits, INT32* pPitch)
{
   *pBits  = m_pScratchBits;
   *pPitch = m_nScratchPitch;
   return HXR_OK;
}

HX_RESULT CUnixRootSurf::ScratchUnlock(UCHAR* pBits)
{
   return HXR_OK;
}

HX_RESULT CUnixRootSurf::_MinimalUnlock(HXxWindow* pWindow)
{
//     Window win = m_window;
//     HX_ASSERT(win);
//     HXxSize hxxSize;
//     m_pSite->GetSize(hxxSize);
   
//     if (m_bUseShm)
//     {
//        XShmPutImage(m_pDisplay,
//                     win,
//                     m_GC,
//                     m_pXImage,
//                     0, 
//                     0,
//                     0,
//                     0,
//                     hxxSize.cx,      
//                     hxxSize.cy,
//                     False
//                     );
//     }
//     else
//     {
//        XPutImage(m_pDisplay,
//                  win,
//                  m_GC,
//                  m_pXImage,
//                  0, 
//                  0,
//                  0,
//                  0,
//                  hxxSize.cx,
//                  hxxSize.cy
//                  );
//     }
     return HXR_OK;
}

HX_RESULT CUnixRootSurf::_LockComposition(UCHAR** pBits, INT32* pPitch)
{
   HX_RESULT retVal = HXR_OK;
   if( !m_bCompositionSurfaceCreated || m_pCompositionSurface==NULL )
   {
      retVal = _CreateCompositionSurface();
   }
   HX_ASSERT( m_pCompositionSurface );
   *pBits  = m_pCompositionSurface;
   *pPitch = m_nCompositionPitch;
   return HXR_OK;
}


void CUnixRootSurf::_BltFromScratchToComposition( HXxRect& rDestRect, HXxRect& rSrcRect)
{
   HX_ASSERT( "Not implemented on unix yet...."==NULL );
}

HX_RESULT CUnixRootSurf::_CreateCompositionSurface()
{
   HX_RESULT retVal = HXR_FAIL;

   if(m_bCompositionSurfaceCreated)
   {
      return HXR_OK;
   }

   HX_ASSERT( !m_bCompositionSurfaceCreated );
   HX_ASSERT( m_pSite );

   //Create a BMI to describe the composition surface
   HXxSize hxxSize;
   m_pSite->GetSize(hxxSize);
   memcpy(&m_compositionSize, &hxxSize, sizeof(HXxSize)); /* Flawfinder: ignore */

   // find out how big we want to allocate.
   if (m_pSite->IsFullScreen())
   {
      UINT16 unDummy=0;
      UINT16 unHorzRes=0;
      UINT16 unVertRes=0;
      m_pSite->_GetDeviceCaps(NULL, unDummy, unHorzRes, unVertRes );
      m_allocatedCompositionSize.cx = unHorzRes;
      m_allocatedCompositionSize.cy = unVertRes;
   }
   else
   {
      m_allocatedCompositionSize.cx = m_compositionSize.cx;
      m_allocatedCompositionSize.cy = m_compositionSize.cy;
   }

   //XXXgfw uhhhh, OK.
   if( m_compositionSize.cx > m_allocatedCompositionSize.cx ||
       m_compositionSize.cy > m_allocatedCompositionSize.cy )
   {
      m_allocatedCompositionSize.cx = m_compositionSize.cx;
      m_allocatedCompositionSize.cy = m_compositionSize.cy;
   }

   //Make the bitmap header struct.
   m_bmiComposition.bmiHeader.biBitCount    = m_bmiSave.bmiHeader.biBitCount;
   m_bmiComposition.bmiHeader.biCompression = m_bmiSave.bmiHeader.biCompression;
   m_bmiComposition.un.dwBitMask[0]         = m_bmiSave.un.dwBitMask[0];
   m_bmiComposition.un.dwBitMask[1]         = m_bmiSave.un.dwBitMask[1];
   m_bmiComposition.un.dwBitMask[2]         = m_bmiSave.un.dwBitMask[2];
   int nResult = MakeBitmap( &m_bmiComposition,
                             sizeof(m_bmiComposition),
                             m_nCompositionSurfaceCID,
                             m_allocatedCompositionSize.cx,
                             m_allocatedCompositionSize.cy,
                             NULL,
                             0
                             );
   m_bmiComposition.bmiHeader.biBitCount    = m_bmiSave.bmiHeader.biBitCount;
   m_bmiComposition.bmiHeader.biCompression = m_bmiSave.bmiHeader.biCompression;
   m_bmiComposition.un.dwBitMask[0]         = m_bmiSave.un.dwBitMask[0];
   m_bmiComposition.un.dwBitMask[1]         = m_bmiSave.un.dwBitMask[1];
   m_bmiComposition.un.dwBitMask[2]         = m_bmiSave.un.dwBitMask[2];

   //Now create the bits....
   _ResizeVideoBuffer( m_bmiComposition.bmiHeader.biSizeImage );
   m_nCompositionPitch = GetBitmapPitch( &m_bmiComposition );

   if( m_pXImage )
   {
      XFree( m_pXImage );
   }

   if( m_bUseShm )
   {
      m_pXImage  = XShmCreateImage( m_pDisplay,
                                    m_pVisual,
                                    m_unDepth,
                                    ZPixmap,
                                    (char*)m_pCompositionSurface,
                                    &m_shmInfo,
                                    m_allocatedCompositionSize.cx,
                                    m_allocatedCompositionSize.cy
                                    );
   }
   else
   {
      m_pXImage  = XCreateImage( m_pDisplay,
                                 m_pVisual,
                                 m_unDepth,
                                 ZPixmap,
                                 0,
                                 (char*)m_pCompositionSurface,
                                 m_allocatedCompositionSize.cx,
                                 m_allocatedCompositionSize.cy,
                                 32,
                                 0);
   }
   
   if( m_pXImage )
   {
      m_bCompositionSurfaceCreated = TRUE;
#ifdef _BIG_ENDIAN
      m_pXImage->byte_order = MSBFirst;
#else
      m_pXImage->byte_order = LSBFirst;
#endif      
      retVal = HXR_OK;
   }
   return retVal;
}

void CUnixRootSurf::_MinimalBlt(HXxRect& srcRect, HXxRect& destRect)
{
   Window win = m_window;
   HX_ASSERT(win);

   if (m_bUseShm)
   {
      XShmPutImage(m_pDisplay,
                   win,
                   m_GC,
                   m_pXImage,
                   destRect.left, 
                   destRect.top,
                   destRect.left,
                   destRect.top,
                   destRect.right - destRect.left,      
                   destRect.bottom - destRect.top,
                   False
                   );
   }
   else
   {
      XPutImage(m_pDisplay,
                win,
                m_GC,
                m_pXImage,
                srcRect.left, 
                srcRect.top,
                destRect.left,
                destRect.top,
                destRect.right - destRect.left,      
                destRect.bottom - destRect.top);
   }
}

HX_RESULT CUnixRootSurf::_DestroyCompositionSurface()
{
   HX_RESULT retVal = HXR_OK;
   if( m_bCompositionSurfaceCreated )
   {
      if( m_pXImage )
      {
         XFree(m_pXImage);
         m_pXImage = NULL;
      }
      m_bCompositionSurfaceCreated = FALSE;
   }
   
   return retVal;
}



HX_RESULT CUnixRootSurf::BeginOptimizedBlt(HXBitmapInfoHeader* pBitmapInfo)
{
#ifdef _DEBUG
   fprintf(stderr, "CUnixRootSurf::BeginOptimizedBlt Needs to be written\n" );
#endif
   return HXR_NOTIMPL;
}

HX_RESULT CUnixRootSurf::OptimizedBlt( UCHAR*   pImageBits,
                                       HXxRect& rDestRect,
                                       HXxRect& rSrcRect)
{
#ifdef _DEBUG
   fprintf(stderr, "CUnixRootSurf::OptimizedBlt Needs to be written\n" );
#endif
   return HXR_NOTIMPL;
}

HX_RESULT CUnixRootSurf::EndOptimizedBlt(void)
{
#ifdef _DEBUG
   fprintf(stderr, "CUnixRootSurf::EndOptimizedBlt Needs to be written\n" );
#endif
   return HXR_NOTIMPL;
}

HX_RESULT CUnixRootSurf::GetOptimizedFormat(HX_COMPRESSION_TYPE& ulType)
{
#ifdef _DEBUG
   fprintf(stderr, "CUnixRootSurf::GetOptimizedFormat Needs to be written\n" );
#endif
   return HXR_NOTIMPL;
}

HX_RESULT CUnixRootSurf::GetPreferredFormat(HX_COMPRESSION_TYPE& ulType)
{
#ifdef _DEBUG
   fprintf(stderr, "CUnixRootSurf::GetPreferredFormat Needs to be written\n" );
#endif
   return HXR_NOTIMPL;
}

GC CUnixRootSurf::GetGC()
{
   return m_GC;
}

⌨️ 快捷键说明

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