📄 winsurf.cpp
字号:
m_surface.dd.lpDDBackBuffer = NULL; } if (NOERROR == WinDrawSurface_Lock(pWindraw, &m_surface, 0, (void**) ppSurfPtr, pnSurfPitch)) ret = HXR_OK; else ret = HXR_FAIL; if (pBackBuffer) m_surface.dd.lpDDBackBuffer = pBackBuffer; return ret;}// Note that the pSurfPtr is not used... but other implementations will// probbaly use it.HX_RESULT CWinSurface::_UnlockInternalSurface(UCHAR* pSurfPtr){ CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface(); WINDRAW* pWindraw = pSurface->GetWinDraw(); if (m_pSite->HasFocusRect()) { pSurface->DrawFocusRect(//&m_surface, m_nSurfaceCID, &m_surfaceSize, pSurfPtr, m_pSite); } IDirectDrawSurface *pBackBuffer = NULL; //This is a VS1 only call. If we are calling this and we are in //VS2 mode then it means we are sharing the overlay. //VS1 only uses the front buffer and so we need to hide the back //buffer from VS1 to keep the flip from happening. //PR70865, Fixes the 'shaking' bug. if( m_bVideoSurface2 && m_surface.dd.lpDDBackBuffer ) { //XXXgfw This assumes that VS1 *NEVER* uses a flipping chain. pBackBuffer = m_surface.dd.lpDDBackBuffer; m_surface.dd.lpDDBackBuffer = NULL; } WinDrawSurface_Unlock(pWindraw, &m_surface, 0); if (pBackBuffer) m_surface.dd.lpDDBackBuffer = pBackBuffer; return HXR_OK;}void CWinSurface::_SetupDCObjects(HXxDC hxxDC, void** phOldBrush, void** phOldPen){ HDC hdc = (HDC) hxxDC; LOGBRUSH brush; brush.lbStyle = BS_SOLID; brush.lbColor = GetOverlayColor(); brush.lbHatch = 0; HBRUSH hBrush = (HBRUSH)CreateBrushIndirect(&brush); HPEN hPen = (HPEN)CreatePen(PS_SOLID, 1, GetOverlayColor()); *phOldBrush = (void*)SelectObject(hdc, hBrush); *phOldPen = (void*)SelectObject(hdc, hPen);}void CWinSurface::_FillRectangle(HXxDC hxxDC, UINT32 left, UINT32 top, UINT32 right, UINT32 bottom){ HDC hdc = (HDC)hxxDC; LOGBRUSH brush; brush.lbStyle = BS_SOLID;// Do NOT use _InsureColorMatch() here. This color must be RGB(8,8,8) format and _InsureColorMatch()// will return a different format if display isn't in 24 or 32-bit mode. brush.lbColor = GetOverlayColor(); brush.lbHatch = 0; HBRUSH hBrush = (HBRUSH)CreateBrushIndirect(&brush); HPEN hPen = (HPEN)CreatePen(PS_SOLID, 1, brush.lbColor); HBRUSH hOldBrush = (HBRUSH)SelectObject(hdc, hBrush); HPEN hOldPen = (HPEN)SelectObject(hdc, hPen); Rectangle(hdc, left, top, right, bottom); SelectObject(hdc, hOldBrush); SelectObject(hdc, hOldPen); DeleteObject(hBrush); DeleteObject(hPen);}void CWinSurface::_RestoreDCObjects(HXxDC hxxDC, void* hOldBrush, void* hOldPen){ HBRUSH hBrush = (HBRUSH)SelectObject((HDC) hxxDC, (HBRUSH) hOldBrush); HPEN hPen = (HPEN)SelectObject((HDC) hxxDC, (HPEN) hOldPen); DeleteObject(hBrush); DeleteObject(hPen);}void CWinSurface::_GetCompositionSurfaceHXxDC(HXxDC *hdc){ CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface(); WINDRAWSURFACE* pDrawSurface = pSurface->GetCompositionSurface(); WINDRAW* pWindraw = pSurface->GetWinDraw(); WinDrawSurface_GetDC(pWindraw, pDrawSurface, (HDC*)hdc); // XXXAH Huh? Fix this up!}void CWinSurface::_ReleaseCompositionSurfaceHXxDC(HXxDC hdc){ CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface(); WINDRAWSURFACE* pDrawSurface = pSurface->GetCompositionSurface(); WINDRAW* pWindraw = pSurface->GetWinDraw(); WinDrawSurface_ReleaseDC(pWindraw, pDrawSurface, (HDC)hdc);}INT32 CWinSurface::_InsureColorMatch(INT32 InColor){ CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface(); WINDRAW* pWindraw = pSurface->GetWinDraw(); return Windraw_ColorMatch(pWindraw, InColor);}void CWinSurface::_SetColorKey(INT32 nColorSpaceLowValue, INT32 nColorSpaceHighValue){ CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface(); WINDRAW* pWindraw = pSurface->GetWinDraw(); HRESULT hr = WinDraw2_SetColorKey(pWindraw, m_convertedOverlayColor, m_convertedOverlayColor);}void CWinSurface::_UpdateOverlay(HXxRect* dest, HXxRect* src, INT32 inFlags){ CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface(); WINDRAW* pWindraw = pSurface->GetWinDraw(); // convert flags. INT32 flags = 0; if (inFlags & HX_OVER_KEYDEST) { flags |= DDOVER_KEYDEST; } if (inFlags & HX_OVER_HIDE) { flags |= DDOVER_HIDE; } if (inFlags & HX_OVER_SHOW) { flags |= DDOVER_SHOW; } HRESULT hr = WinDraw2_UpdateOverlay(pWindraw, &m_surface, (RECT*)dest, (RECT*)src, flags); // We can only have one visible overlay and someone else has it :( // Drop to offscreen mode. if (DDERR_OUTOFCAPS == hr) { m_nBltMode = HX_BASIC_BLT; m_bMultipleOverlay = !m_bLostHWAcceleration;//TRUE; } // If we lost/restored our surfaces, the video will be garbage so force // a redraw. else if (DDERR_SURFACELOST == hr) m_nLastBltMode = HX_NO_BLT;}BOOL CWinSurface::_IsSurfaceVisible(){ CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface(); if (!pSurface) return FALSE; WINDRAW* pWindraw = pSurface->GetWinDraw(); return WinDraw2_IsSurfaceVisible(pWindraw, &m_surface);}void CWinSurface::_ReleaseSurface(){ CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface(); if (pSurface) { WINDRAW* pWindraw = pSurface->GetWinDraw(); if (pWindraw) { WinDraw2_ReleaseSurface(pWindraw, &m_surface); } } m_nLastBltMode = HX_NO_BLT;}HXxDC CWinSurface::_GetDC(HXxWindow* pWindow){ HWND hwnd = (HWND) pWindow->window; return (HXxDC) GetDC(hwnd);}void CWinSurface::_ReleaseDC(HXxWindow* pWindow, HXxDC hdc){ HWND hwnd = (HWND) pWindow->window; ReleaseDC(hwnd, (HDC)hdc);}void CWinSurface::_GetWindowDeviceCords(HXxRect* rect){ HXxWindow* pWin = m_pSite->GetWindow(); if( pWin ) { HWND hwnd = (HWND) pWin->window; GetWindowRect(hwnd,(RECT*)rect); }}HX_RESULT CWinSurface::RelinquishOverlay(){ return CBaseSurface::RelinquishOverlay();}HX_RESULT CWinSurface::AcquireOverlay(){ return CBaseSurface::AcquireOverlay();}void CWinSurface::_ColorWindows(){ int index = m_pSite->m_pTopLevelSite->m_nWindowColor++; if (m_pSite && m_pSite->GetWindow()) { HWND hwnd = (HWND) (m_pSite->GetWindow())->window; HDC hdc = GetDC(hwnd); LOGBRUSH logBrush; logBrush.lbStyle = BS_SOLID; UCHAR red = (index) * 16; UCHAR green = (index+5) * 16; UCHAR blue = (index+10) * 16; logBrush.lbColor = (red << 16) | (green <<8) | blue; logBrush.lbHatch = 0; HBRUSH brush = CreateBrushIndirect(&logBrush); HBRUSH oldBrush = (HBRUSH) SelectObject(hdc, brush); Rectangle(hdc, 0,0, 1000, 1000); SelectObject(hdc, oldBrush); DeleteObject(brush); ReleaseDC(hwnd, hdc); RECT rect; ::GetWindowRect(hwnd, &rect); FILE* f = fopen("c:\\color.txt", "a+"); /* Flawfinder: ignore */ fprintf(f, "%p HWND %p %p (%d, %d, %d, %d)\n", this, hwnd, logBrush.lbColor, rect.left, rect.top, rect.right, rect.bottom); HRGN r = CreateRectRgn(0,0,0,0); GetWindowRgn( hwnd, r); DWORD dwCount = GetRegionData( r, 0, 0); char* p = (char* ) calloc(dwCount, 1); LPRGNDATA pdata = (LPRGNDATA)p; DWORD ret = GetRegionData( r, dwCount, pdata); fprintf(f, "\tCount: %d Size: %d\n", pdata->rdh.nCount, dwCount); RECT* pr = (RECT*)pdata->Buffer; for(int i = 0; i< pdata->rdh.nCount; i++) fprintf(f, "\t\t(%d, %d, %d, %d)\n", pr[i]); DeleteObject(r); free(p); fclose(f); }}BOOL CWinSurface::UsingOverlay(){ if (m_surface.fMode & WINDRAWSURFACE_OVERLAY) { return TRUE; } if (m_pLinkedOverlay) { return m_pLinkedOverlay->UsingOverlay(); } return FALSE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -