winsurf.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:18k
源码类别:

Symbian

开发平台:

C/C++

  1. /* ***** BEGIN LICENSE BLOCK ***** 
  2.  * Version: RCSL 1.0/RPSL 1.0 
  3.  *  
  4.  * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 
  5.  *      
  6.  * The contents of this file, and the files included with this file, are 
  7.  * subject to the current version of the RealNetworks Public Source License 
  8.  * Version 1.0 (the "RPSL") available at 
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed 
  10.  * the file under the RealNetworks Community Source License Version 1.0 
  11.  * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 
  12.  * in which case the RCSL will apply. You may also obtain the license terms 
  13.  * directly from RealNetworks.  You may not use this file except in 
  14.  * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 
  15.  * applicable to this file, the RCSL.  Please see the applicable RPSL or 
  16.  * RCSL for the rights, obligations and limitations governing use of the 
  17.  * contents of the file.  
  18.  *  
  19.  * This file is part of the Helix DNA Technology. RealNetworks is the 
  20.  * developer of the Original Code and owns the copyrights in the portions 
  21.  * it created. 
  22.  *  
  23.  * This file, and the files included with this file, is distributed and made 
  24.  * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  25.  * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  26.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 
  27.  * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  28.  * 
  29.  * Technology Compatibility Kit Test Suite(s) Location: 
  30.  *    http://www.helixcommunity.org/content/tck 
  31.  * 
  32.  * Contributor(s): 
  33.  *  
  34.  * ***** END LICENSE BLOCK ***** */ 
  35. #include "hxtypes.h"
  36. #include <math.h>
  37. #include "ddraw.h"
  38. #include "hxcom.h"
  39. #include "hxmtypes.h"
  40. #include "hxwintyp.h"
  41. #include "hxvsurf.h"
  42. #include "hxslist.h"
  43. #include "winsurf.h"
  44. #include "winsite.h"
  45. #include "colormap.h"
  46. #include "hxprefs.h"
  47. #include "hxtick.h"
  48. #include "hxheap.h"
  49. #include "hxevent.h"
  50. // these are defined in basesurf.cpp and should probably be moved to a .h file
  51. #define HX_OVER_KEYDEST    1
  52. #define HX_OVER_HIDE       2
  53. #define HX_OVER_SHOW       4  
  54. #define OVERLAY_NOT_VISIBLE 0
  55. #ifdef _DEBUG
  56. #undef HX_THIS_FILE             
  57. static const char HX_THIS_FILE[] = __FILE__;
  58. #include "winthrd.h"
  59. #endif
  60. CWinSurface::CWinSurface(IUnknown* pContext, CHXBaseSite* pSite) :
  61.     CBaseSurface(pContext,pSite)
  62.  ,  m_nBitsPerPixel(0)
  63.  ,  m_nHozRes(0)
  64.  ,  m_nVertRes(0)
  65.  ,  m_nLastBltMode(HX_NO_BLT)
  66. {
  67.     // initialize data so we don't have invalid ptrs floating around.
  68.     memset(&m_surface,0,sizeof(m_surface));
  69. }
  70. CWinSurface::~CWinSurface()
  71. {
  72. }
  73. void CWinSurface::_ReleaseSurface(CBaseRootSurface* pSurface)
  74. {
  75.     WINDRAW* pWindraw = ((CWinBaseRootSurface*)pSurface)->GetWinDraw();
  76.     WinDraw2_ReleaseSurface(pWindraw, &m_surface);
  77.     m_nLastBltMode = HX_NO_BLT;
  78. }
  79. void CWinSurface::_ReleaseSurface(CWinBaseRootSurface* pSurface)
  80. {
  81.     WINDRAW* pWindraw = pSurface->GetWinDraw();
  82.     WinDraw2_ReleaseSurface(pWindraw, &m_surface);
  83.     m_nLastBltMode = HX_NO_BLT;
  84. }
  85. void CWinSurface::_DrawBlack(void* pWindow)
  86. {
  87. }
  88. void CWinSurface::_CreateBuffer()
  89. {
  90.     CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface();
  91.     pSurface->OpenWindraw();
  92.     WINDRAW* pWindraw = pSurface->GetWinDraw();
  93.         
  94.     BMI bmi;
  95.     memset(&bmi, 0, sizeof(BMI));
  96.     WinDraw2_GetDisplayFormat(pWindraw, &bmi);
  97.     int cid = GetBitmapColor((LPBITMAPINFO)&bmi);
  98.         
  99.     memset(&bmi, 0, sizeof(BMI));
  100.     MakeBitmap((LPBITMAPINFO)&bmi, sizeof(BMI), cid, m_pOptimizedFormat->biWidth, m_pOptimizedFormat->biHeight, NULL, NULL);
  101.     memset(&m_surface, 0, sizeof(WINDRAWSURFACE));
  102.     
  103.     if (NOERROR == WinDraw2_CreateSurface(pWindraw, &m_surface, &bmi, pSurface->GetSurfaceType(), 0, 0))
  104.     {
  105.         m_surfaceSize.cx = m_pOptimizedFormat->biWidth;
  106.         m_surfaceSize.cy = m_pOptimizedFormat->biHeight;
  107.         m_nSurfaceCID = cid;
  108.         m_nBltMode = HX_BLT_YUV_STRETCH;
  109.         if (!m_nBitsPerPixel ||
  110.             !m_nHozRes ||
  111.             !m_nVertRes)
  112.         {
  113.             // Store the display mode we were created in.
  114.             m_pSite->_GetDeviceCaps(NULL, m_nBitsPerPixel, m_nHozRes, m_nVertRes);
  115.         }
  116.     }
  117. }
  118. HX_RESULT CWinSurface::_GetCaps(UINT32 *pfSurfaceCaps)
  119. {
  120.     CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface();
  121.     pSurface->OpenWindraw();
  122.     WINDRAW* pWindraw = pSurface->GetWinDraw();
  123.         
  124.     //    UINT32 fSurfaceCaps;
  125.     UINT32 garbagea, garbageb;
  126.         
  127.     if (NOERROR != Windraw_GetCaps(pWindraw, pfSurfaceCaps, &garbagea, &garbageb))
  128.     {
  129.         return HXR_FAIL;
  130.     }
  131.     else
  132.     {
  133.         return HXR_OK;
  134.     }
  135. }
  136. HX_RESULT CWinSurface::_CreateOverlay(BOOL bOverlay, int cid, int x, int y)
  137. {
  138.     //Get our windraw object from the root surface
  139.     CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface();
  140.    
  141.     HX_ASSERT( pSurface );
  142.     if( !pSurface )
  143.         return HXR_FAIL;
  144.    
  145.     pSurface->OpenWindraw();
  146.     WINDRAW* pWindraw = pSurface->GetWinDraw();
  147.     BMI bmi;
  148.     memset(&bmi, 0, sizeof(BMI));
  149.     MakeBitmap((LPBITMAPINFO)&bmi, sizeof(BMI), cid, x, y, NULL, NULL);
  150.     memset(&m_surface, 0, sizeof(WINDRAWSURFACE));
  151.         
  152.     int fFlags = 0;
  153.         
  154.     if (bOverlay)
  155.     {
  156.         fFlags = WINDRAWSURFACE_DIRECTDRAW | WINDRAWSURFACE_OVERLAY | WINDRAWSURFACE_VIDEOMEMORY;
  157.     }
  158.     else
  159.     {
  160.         fFlags = WINDRAWSURFACE_DIRECTDRAW | WINDRAWSURFACE_DEFAULTMEMORY;
  161.     }
  162.         
  163.     int numBuffers = (m_bFlipOverlay && bOverlay) ? m_nBackBufferCount+1 : 1;
  164.     for (; numBuffers; numBuffers--)
  165.     {
  166.         if (NOERROR == WinDraw2_CreateSurface(pWindraw, &m_surface, &bmi, fFlags, numBuffers-1, 0))
  167.         {
  168.             m_nDDSurfaceSize = bmi.bmiHeader.biSizeImage;
  169.             m_surfaceSize.cx = x;
  170.             m_surfaceSize.cy = y;
  171.             m_nSurfaceCID = cid;
  172.             m_nBackBufferCount = numBuffers-1;
  173.             if (bOverlay)
  174.             {
  175.                 m_nBltMode = HX_OVERLAY_BLT;
  176.             }
  177.             else
  178.             {
  179.                 m_nBltMode = HX_BLT_YUV_STRETCH;
  180.             }
  181.             UpdateDestRect();
  182.             if (!m_nBitsPerPixel ||
  183.                 !m_nHozRes ||
  184.                 !m_nVertRes)
  185.             {
  186.                 // Store the display mode we were created in.
  187.                 m_pSite->_GetDeviceCaps(NULL, m_nBitsPerPixel, m_nHozRes, m_nVertRes);
  188.             }
  189.             return HXR_OK;
  190.         }
  191.     }
  192.         
  193.     return HXR_FAIL;
  194. }
  195. HX_RESULT CWinSurface::_BltToPrimary(REF(HXxRect) rDestRect, REF(HXxRect) rSrcRect)
  196. {
  197. #ifdef _CHECK_PERFORMANCE
  198.     static LARGE_INTEGER QueryPerformanceCounterResult = {0,0};
  199.     static LARGE_INTEGER QueryPerformanceFrequencyResult = {0,0};
  200.         
  201.     QueryPerformanceFrequency(&QueryPerformanceFrequencyResult);
  202.         
  203.     double frequency = ((double)QueryPerformanceFrequencyResult.LowPart + 4294967296.0*QueryPerformanceFrequencyResult.HighPart);
  204.     QueryPerformanceCounter(&QueryPerformanceCounterResult);
  205.         
  206.     double startTime = ((double)QueryPerformanceCounterResult.LowPart + 4294967296.0*QueryPerformanceCounterResult.HighPart)/frequency;
  207. #endif
  208.         
  209.     if ((m_surfaceSize.cx==0  && m_surfaceSize.cy == 0)  || HX_BLT_YUV_STRETCH != m_nBltMode )
  210.     {
  211.         return HXR_FAIL;
  212.     }
  213.         
  214.     CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface();
  215.     WINDRAW* pWindraw = pSurface->GetWinDraw();
  216.         
  217.     HX_RESULT retVal = HXR_FAIL;
  218.         
  219.     if (NOERROR == WinDrawSurface_Blt(pWindraw, &m_surface, (RECT*)&rDestRect, (RECT*)&rSrcRect))
  220.     {
  221.         retVal = HXR_OK;        
  222.     }
  223.         
  224. #ifdef _CHECK_PERFORMANCE
  225.     QueryPerformanceCounter(&QueryPerformanceCounterResult);
  226.     double endTime = ((double)QueryPerformanceCounterResult.LowPart + 4294967296.0*QueryPerformanceCounterResult.HighPart)/frequency;
  227.         
  228.     static UINT32 z_nNumTimes = 0;
  229.     static double z_fTotalTime;
  230.     static double z_fAverageTime;
  231.         
  232.     z_nNumTimes++;
  233.     z_fTotalTime += endTime - startTime;
  234.     z_fAverageTime = z_fTotalTime / (double) z_nNumTimes;
  235.         
  236.     if (! (z_nNumTimes % 25))
  237.     {
  238.         FILE* f1 = ::fopen("c:\performance.txt", "a+"); /* Flawfinder: ignore */
  239.         ::fprintf(f1, "WINDRAW2 - BltToPrimary: %d blts. Total CPU time: %f, CPU/Blt: %f -- Blt/s Second Max: %fn", z_nNumTimes, z_fTotalTime, z_fAverageTime, 1.0/z_fAverageTime);
  240.         fclose(f1);
  241.     }
  242. #endif
  243.     return retVal;
  244. }
  245. HX_RESULT CWinSurface::_LockInternalSurface(UCHAR** ppSurfPtr, LONG* pnSurfPitch, REF(HXxSize) srcSize)
  246. {
  247.     HX_RESULT ret = HXR_OK;
  248.     IDirectDrawSurface *pBackBuffer = NULL;
  249.     
  250.     CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface();
  251.     WINDRAW* pWindraw = pSurface->GetWinDraw();
  252.     //See comments in _UnlockInternalSurface below.....
  253.     if( m_bVideoSurface2 && m_surface.dd.lpDDBackBuffer )
  254.     {
  255.         pBackBuffer = m_surface.dd.lpDDBackBuffer;
  256.         m_surface.dd.lpDDBackBuffer = NULL;
  257.     }
  258.     if (NOERROR == WinDrawSurface_Lock(pWindraw, &m_surface, 0, (void**) ppSurfPtr, pnSurfPitch))
  259.         ret =  HXR_OK;
  260.     else
  261.         ret = HXR_FAIL;
  262.     
  263.     if (pBackBuffer)
  264.         m_surface.dd.lpDDBackBuffer = pBackBuffer;
  265.         
  266.     return ret;
  267. }
  268. // Note that the pSurfPtr is not used... but other implementations will
  269. // probbaly use it.
  270. HX_RESULT CWinSurface::_UnlockInternalSurface(UCHAR* pSurfPtr)
  271. {
  272.     CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface();
  273.     WINDRAW* pWindraw = pSurface->GetWinDraw();
  274.     if (m_pSite->HasFocusRect())
  275.     {
  276.         pSurface->DrawFocusRect(//&m_surface,
  277.             m_nSurfaceCID,
  278.             &m_surfaceSize,
  279.             pSurfPtr,
  280.             m_pSite);
  281.     }
  282.     
  283.     IDirectDrawSurface *pBackBuffer = NULL;
  284.     
  285.     //This is a VS1 only call. If we are calling this and we are in
  286.     //VS2 mode then it means we are sharing the overlay.
  287.     //VS1 only uses the front buffer and so we need to hide the back
  288.     //buffer from VS1 to keep the flip from happening.
  289.     //PR70865, Fixes the 'shaking' bug.
  290.     if( m_bVideoSurface2 && m_surface.dd.lpDDBackBuffer )
  291.     {
  292.         //XXXgfw This assumes that VS1 *NEVER* uses a flipping chain.
  293.         pBackBuffer = m_surface.dd.lpDDBackBuffer;
  294.         m_surface.dd.lpDDBackBuffer = NULL;
  295.     }
  296.     WinDrawSurface_Unlock(pWindraw, &m_surface, 0);
  297.     if (pBackBuffer)
  298.         m_surface.dd.lpDDBackBuffer = pBackBuffer;
  299.         
  300.     return HXR_OK;
  301. }
  302. void CWinSurface::_SetupDCObjects(HXxDC hxxDC, void** phOldBrush, void** phOldPen)
  303. {
  304.     HDC hdc = (HDC) hxxDC;
  305.         
  306.     LOGBRUSH brush;
  307.         
  308.     brush.lbStyle = BS_SOLID;
  309.     brush.lbColor = GetOverlayColor();
  310.     brush.lbHatch = 0;
  311.         
  312.     HBRUSH  hBrush      = (HBRUSH)CreateBrushIndirect(&brush);
  313.     HPEN    hPen        = (HPEN)CreatePen(PS_SOLID, 1, GetOverlayColor());
  314.     *phOldBrush         = (void*)SelectObject(hdc, hBrush);
  315.     *phOldPen           = (void*)SelectObject(hdc, hPen);
  316. }
  317. void CWinSurface::_FillRectangle(HXxDC hxxDC, UINT32 left, UINT32 top, UINT32 right, UINT32 bottom)
  318. {
  319.     HDC hdc = (HDC)hxxDC;
  320.     LOGBRUSH brush;
  321.         
  322.     brush.lbStyle = BS_SOLID;
  323. //  Do NOT use _InsureColorMatch() here.  This color must be RGB(8,8,8) format and _InsureColorMatch()
  324. //  will return a different format if display isn't in 24 or 32-bit mode.
  325.     brush.lbColor = GetOverlayColor();
  326.     brush.lbHatch = 0;
  327.         
  328.     HBRUSH  hBrush      = (HBRUSH)CreateBrushIndirect(&brush);
  329.     HPEN    hPen        = (HPEN)CreatePen(PS_SOLID, 1, brush.lbColor);
  330.     HBRUSH  hOldBrush   = (HBRUSH)SelectObject(hdc, hBrush);
  331.     HPEN    hOldPen     = (HPEN)SelectObject(hdc, hPen);
  332.         
  333.     Rectangle(hdc, left, top, right, bottom);
  334.         
  335.     SelectObject(hdc, hOldBrush);
  336.     SelectObject(hdc, hOldPen);
  337.     DeleteObject(hBrush);
  338.     DeleteObject(hPen);
  339. }
  340. void CWinSurface::_RestoreDCObjects(HXxDC hxxDC, void* hOldBrush, void* hOldPen)
  341. {
  342.     HBRUSH hBrush = (HBRUSH)SelectObject((HDC) hxxDC, (HBRUSH) hOldBrush);
  343.     HPEN hPen = (HPEN)SelectObject((HDC) hxxDC, (HPEN) hOldPen);
  344.     DeleteObject(hBrush);
  345.     DeleteObject(hPen);
  346. }
  347. void CWinSurface::_GetCompositionSurfaceHXxDC(HXxDC *hdc)
  348. {
  349.     CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface();
  350.     WINDRAWSURFACE* pDrawSurface = pSurface->GetCompositionSurface();
  351.     WINDRAW*    pWindraw = pSurface->GetWinDraw();
  352.         
  353.     WinDrawSurface_GetDC(pWindraw, pDrawSurface, (HDC*)hdc);
  354.     // XXXAH Huh? Fix this up!
  355. }
  356. void CWinSurface::_ReleaseCompositionSurfaceHXxDC(HXxDC hdc)
  357. {
  358.     CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface();
  359.     WINDRAWSURFACE* pDrawSurface = pSurface->GetCompositionSurface();
  360.     WINDRAW*    pWindraw = pSurface->GetWinDraw();
  361.         
  362.     WinDrawSurface_ReleaseDC(pWindraw, pDrawSurface, (HDC)hdc);
  363. }
  364. INT32 CWinSurface::_InsureColorMatch(INT32 InColor)
  365. {
  366.     CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface();
  367.     WINDRAW*    pWindraw = pSurface->GetWinDraw();
  368.     return Windraw_ColorMatch(pWindraw, InColor);
  369. }
  370. void CWinSurface::_SetColorKey(INT32 nColorSpaceLowValue, INT32 nColorSpaceHighValue)
  371. {
  372.     CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface();
  373.     WINDRAW*    pWindraw = pSurface->GetWinDraw();
  374.     HRESULT hr = WinDraw2_SetColorKey(pWindraw, m_convertedOverlayColor, m_convertedOverlayColor);
  375. }
  376. void CWinSurface::_UpdateOverlay(HXxRect* dest, HXxRect* src, INT32 inFlags)
  377. {
  378.     CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface();
  379.     WINDRAW*    pWindraw = pSurface->GetWinDraw();
  380.         
  381.     // convert flags.
  382.     INT32 flags = 0;
  383.     
  384.     if (inFlags & HX_OVER_KEYDEST)
  385.     {   
  386.         flags |= DDOVER_KEYDEST;
  387.     }
  388.         
  389.     if (inFlags & HX_OVER_HIDE)
  390.     {   
  391.         flags |= DDOVER_HIDE;
  392.     }
  393.         
  394.     if (inFlags & HX_OVER_SHOW)
  395.     {   
  396.         flags |= DDOVER_SHOW;
  397.     }
  398.     HRESULT hr = WinDraw2_UpdateOverlay(pWindraw, &m_surface, (RECT*)dest, (RECT*)src, flags);
  399.     // We can only have one visible overlay and someone else has it :(
  400.     // Drop to offscreen mode.
  401.     if (DDERR_OUTOFCAPS == hr)
  402.     {
  403.         m_nBltMode = HX_BASIC_BLT;
  404.         m_bMultipleOverlay = !m_bLostHWAcceleration;//TRUE;
  405.     }
  406.     // If we lost/restored our surfaces, the video will be garbage so force
  407.     // a redraw.
  408.     else if (DDERR_SURFACELOST == hr)
  409.         m_nLastBltMode = HX_NO_BLT;
  410. }
  411. BOOL CWinSurface::_IsSurfaceVisible()
  412. {
  413.     CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface();
  414.     if (!pSurface)
  415.         return FALSE;
  416.     WINDRAW* pWindraw = pSurface->GetWinDraw();
  417.     return WinDraw2_IsSurfaceVisible(pWindraw, &m_surface);
  418. }
  419. void CWinSurface::_ReleaseSurface()
  420. {
  421.     CWinBaseRootSurface* pSurface = (CWinBaseRootSurface*)m_pSite->GetRootSurface();
  422.     if (pSurface)
  423.     {
  424.         WINDRAW* pWindraw = pSurface->GetWinDraw();
  425.         if (pWindraw)
  426.         {
  427.             WinDraw2_ReleaseSurface(pWindraw, &m_surface);
  428.         }
  429.     }
  430.     m_nLastBltMode = HX_NO_BLT;
  431. }
  432. HXxDC CWinSurface::_GetDC(HXxWindow* pWindow)
  433. {
  434.     HWND hwnd = (HWND) pWindow->window;
  435.     return     (HXxDC) GetDC(hwnd);
  436. }
  437. void CWinSurface::_ReleaseDC(HXxWindow* pWindow, HXxDC hdc)
  438. {
  439.     HWND hwnd = (HWND) pWindow->window;
  440.     ReleaseDC(hwnd, (HDC)hdc);
  441. }
  442. void CWinSurface::_GetWindowDeviceCords(HXxRect* rect)
  443. {
  444.     HXxWindow* pWin = m_pSite->GetWindow();
  445.     if( pWin )
  446.     {
  447.         HWND hwnd = (HWND) pWin->window;
  448.         GetWindowRect(hwnd,(RECT*)rect);
  449.     }
  450. }
  451. HX_RESULT CWinSurface::RelinquishOverlay()
  452. {
  453.     return CBaseSurface::RelinquishOverlay();
  454. }
  455. HX_RESULT CWinSurface::AcquireOverlay()
  456. {
  457.     return CBaseSurface::AcquireOverlay();
  458. }
  459. void CWinSurface::_ColorWindows()
  460. {
  461.     int index = m_pSite->m_pTopLevelSite->m_nWindowColor++;
  462.     if (m_pSite && m_pSite->GetWindow())
  463.     {
  464.         HWND hwnd = (HWND) (m_pSite->GetWindow())->window;
  465.         HDC hdc = GetDC(hwnd);
  466.         LOGBRUSH logBrush;
  467.         logBrush.lbStyle = BS_SOLID;
  468.         UCHAR red   =  (index) * 16;
  469.         UCHAR green =  (index+5) * 16;
  470.         UCHAR blue  =  (index+10) * 16;
  471.         logBrush.lbColor = (red << 16) | (green <<8) | blue;
  472.         logBrush.lbHatch = 0;
  473.         HBRUSH brush = CreateBrushIndirect(&logBrush);
  474.         HBRUSH oldBrush = (HBRUSH) SelectObject(hdc, brush);
  475.         Rectangle(hdc, 0,0, 1000, 1000);
  476.         SelectObject(hdc, oldBrush);
  477.         DeleteObject(brush);
  478.         ReleaseDC(hwnd, hdc);
  479.         RECT rect;
  480.         ::GetWindowRect(hwnd, &rect);
  481.         FILE* f = fopen("c:\color.txt", "a+"); /* Flawfinder: ignore */
  482.         fprintf(f, "%p HWND %p %p (%d, %d, %d, %d)n", this, hwnd, logBrush.lbColor, rect.left, rect.top, rect.right, rect.bottom);
  483.         HRGN r = CreateRectRgn(0,0,0,0);
  484.         GetWindowRgn( hwnd, r);
  485.         DWORD dwCount = GetRegionData( r, 0, 0);
  486.         char* p = (char* ) calloc(dwCount, 1);
  487.         LPRGNDATA pdata = (LPRGNDATA)p;
  488.         DWORD ret = GetRegionData( r, dwCount, pdata);
  489.         fprintf(f, "tCount: %d Size: %dn", pdata->rdh.nCount, dwCount);
  490.         RECT* pr = (RECT*)pdata->Buffer;
  491.         for(int i = 0; i< pdata->rdh.nCount; i++)
  492.             fprintf(f, "tt(%d, %d, %d, %d)n", pr[i]);
  493.         DeleteObject(r);
  494.         free(p);
  495.         fclose(f);
  496.     }
  497. }
  498. BOOL  CWinSurface::UsingOverlay()
  499. {
  500.     if (m_surface.fMode & WINDRAWSURFACE_OVERLAY)
  501.     {
  502.         return TRUE;
  503.     }
  504.     if (m_pLinkedOverlay)
  505.     {
  506.         return m_pLinkedOverlay->UsingOverlay();
  507.     }
  508.     return FALSE;
  509. }