basesite.cpp
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:211k
- STDMETHODIMP CHXBaseSite::SetSharpness(float sharpness)
- {
- if (m_pParentSite)
- {
- return m_pParentSite->SetSharpness(sharpness);
- }
- m_fSharpness = sharpness;
- ScheduleCallback(REPAINT, 0);
- return HXR_OK;
- }
- STDMETHODIMP CHXBaseSite::SetModeSharpness(UINT16 dFlag)
- {
- m_bModeSharpness = dFlag;
- return HXR_OK;
- }
- STDMETHODIMP_(BOOL) CHXBaseSite::IsInterruptSafe()
- {
- return TRUE;
- }
- STDMETHODIMP CHXBaseSite::SetKeyboardFocus(IHXSiteUser* pSiteUser)
- {
- #ifdef FUTURE_WORKING_FOCUS
- if (m_pTopLevelSite->m_pKeyBoardFocusUser)
- {
- HXxEvent event = {HX_LOSE_FOCUS, m_pWindow ? m_pWindow->window : NULL, NULL, NULL, 0, 0};
- m_pTopLevelSite->m_pKeyBoardFocusUser->HandleEvent(&event);
- m_pTopLevelSite->m_pKeyBoardFocusUser->Release();
- m_pTopLevelSite->m_pKeyBoardFocusUser = NULL;
- }
- if (pSiteUser)
- {
- m_pTopLevelSite->m_pKeyBoardFocusUser = pSiteUser;
- m_pTopLevelSite->m_pKeyBoardFocusUser->AddRef();
- HXxEvent event = {HX_SET_FOCUS, m_pWindow ? m_pWindow->window : NULL, NULL, NULL, 0, 0};
- m_pTopLevelSite->m_pKeyBoardFocusUser->HandleEvent(&event);
- }
- #else
- HXxWindow* pFocusWindow = GetWindow();
- if(pFocusWindow && pFocusWindow->window)
- {
- SafeSetFocus(pFocusWindow);
- }
- #endif // FUTURE_WORKING_FOCUS
- return HXR_OK;
- }
- STDMETHODIMP CHXBaseSite::GetKeyboardFocus(IHXSiteUser* &pSiteUser)
- {
- pSiteUser = m_pTopLevelSite->m_pKeyBoardFocusUser;
- if (pSiteUser)
- {
- pSiteUser->AddRef();
- return HXR_OK;
- }
- else
- return HXR_FAILED;
- }
- STDMETHODIMP CHXBaseSite::SetStyle(IHXValues* pProperties)
- {
- // Map IHXValues to drawing properties
- ULONG32 ulTemp = HX_SOLID_LINE;
- pProperties->GetPropertyULONG32("LINE_STYLE", ulTemp);
- m_rcFocusRect.ulLineStyle = ulTemp;
- // Store custom line pattern
- HX_RELEASE(m_rcFocusRect.pCustomPattern);
- m_rcFocusRect.ulCustomEntries = 0;
- if (ulTemp == HX_CUSTOM_LINE)
- {
- pProperties->GetPropertyBuffer("CUSTOM_LINE_PATTERN", m_rcFocusRect.pCustomPattern);
- if (m_rcFocusRect.pCustomPattern)
- {
- m_rcFocusRect.pCustomPattern->AddRef();
- ulTemp = 0;
- pProperties->GetPropertyULONG32("CUSTOM_LINE_ENTRIES", ulTemp);
- m_rcFocusRect.ulCustomEntries = ulTemp;
- }
- }
- // Store line width
- ulTemp = 1;
- pProperties->GetPropertyULONG32("LINE_WIDTH", ulTemp);
- m_rcFocusRect.ulLineWidth = ulTemp;
- // Store primary color
- ulTemp = 0;
- pProperties->GetPropertyULONG32("RED", ulTemp);
- m_rcFocusRect.red = (UINT8)ulTemp;
- ulTemp = 0;
- pProperties->GetPropertyULONG32("GREEN", ulTemp);
- m_rcFocusRect.green = (UINT8)ulTemp;
- ulTemp = 0;
- pProperties->GetPropertyULONG32("BLUE", ulTemp);
- m_rcFocusRect.blue = (UINT8)ulTemp;
- m_rcFocusRect.bSecondaryColors = FALSE;
- // Store secondary color
- ulTemp = 0;
- if (HXR_OK == pProperties->GetPropertyULONG32("RED2", ulTemp))
- m_rcFocusRect.bSecondaryColors = TRUE;
- m_rcFocusRect.red2 = (UINT8)ulTemp;
- ulTemp = 0;
- if (HXR_OK == pProperties->GetPropertyULONG32("GREEN2", ulTemp))
- m_rcFocusRect.bSecondaryColors = TRUE;
- m_rcFocusRect.green2 = (UINT8)ulTemp;
- ulTemp = 0;
- if (HXR_OK == pProperties->GetPropertyULONG32("BLUE2", ulTemp))
- m_rcFocusRect.bSecondaryColors = TRUE;
- m_rcFocusRect.blue2 = (UINT8)ulTemp;
- return HXR_OK;
- }
- STDMETHODIMP CHXBaseSite::ClearFocus()
- {
- m_rcFocusRect.bRectActive = FALSE;
- // Clear the focus rect but preserve the properties
- if (m_rcFocusRect.ulShape & DRAW_POLYGON)
- {
- m_rcFocusRect.ulShape &= ~DRAW_POLYGON;
- if (m_rcFocusRect.polygon.pFocusPoints)
- {
- delete [] m_rcFocusRect.polygon.pFocusPoints;
- m_rcFocusRect.polygon.pFocusPoints = NULL;
- m_rcFocusRect.polygon.ulFocusPoints = 0;
- }
- }
- else
- {
- m_rcFocusRect.ulShape &= ~DRAW_RECT;
- m_rcFocusRect.ulShape &= ~DRAW_ELLIPSE;
- memset(&m_rcFocusRect.rcFocus, 0, sizeof(m_rcFocusRect.rcFocus));
- }
- return HXR_OK;
- }
- STDMETHODIMP CHXBaseSite::SetFocusPolygon(HXxPoint* pPoints, ULONG32 numPoints)
- {
- if (!m_rcFocusRect.ulLineWidth)
- return HXR_FAIL;
- if (m_rcFocusRect.bRectActive)
- ClearFocus();
- m_rcFocusRect.polygon.ulFocusPoints = numPoints;
- m_rcFocusRect.polygon.pFocusPoints = new HXxPoint[numPoints];
- m_rcFocusRect.ulShape |= DRAW_POLYGON;
- for (ULONG32 i=0; i<numPoints; i++)
- m_rcFocusRect.polygon.pFocusPoints[i] = pPoints[i];
- m_rcFocusRect.bRectActive = TRUE;
- return HXR_OK;
- }
- STDMETHODIMP CHXBaseSite::SetFocusRect(HXxRect* pRect)
- {
- if (!m_rcFocusRect.ulLineWidth)
- return HXR_FAIL;
- if (m_rcFocusRect.bRectActive)
- ClearFocus();
- m_rcFocusRect.rcFocus = *pRect;
- m_rcFocusRect.ulShape |= DRAW_RECT;
- m_rcFocusRect.bRectActive = TRUE;
- return HXR_OK;
- }
- STDMETHODIMP CHXBaseSite::SetFocusEllipse(HXxRect* pRect)
- {
- if (!m_rcFocusRect.ulLineWidth)
- return HXR_FAIL;
- if (m_rcFocusRect.bRectActive)
- ClearFocus();
- m_rcFocusRect.rcFocus = *pRect;
- m_rcFocusRect.ulShape |= DRAW_ELLIPSE;
- m_rcFocusRect.bRectActive = TRUE;
- return HXR_OK;
- }
- void CHXBaseSite::_DrawFocusRect(UCHAR* pImage,
- HXBitmapInfoHeader* pImageInfo,
- HXxRect* pImageRect,
- void* pOsSpecificData)
- {
- // Do we have an active rect
- if (!m_rcFocusRect.bRectActive)
- return;
- // Only support rgb for now
- if (IsYUV(GETBITMAPCOLOR(pImageInfo)))
- return;
- int *pUpperLeft = (int*)pImage + (pImageRect->left + pImageRect->top) * pImageInfo->biBitCount/8;
- INT32 nStyle = SOLID_LINE;
- if (m_rcFocusRect.ulLineStyle == HX_DASHED_LINE)
- nStyle = DASHED_LINE;
- else if (m_rcFocusRect.ulLineStyle == HX_DOTTED_LINE)
- nStyle = DOTTED_LINE;
- else if (m_rcFocusRect.ulLineStyle == HX_CUSTOM_LINE)
- nStyle = CUSTOM_LINE;
- INT32 *pCustomPattern = NULL;
- if (m_rcFocusRect.pCustomPattern)
- pCustomPattern = (INT32*)(m_rcFocusRect.pCustomPattern->GetBuffer());
- PixelProps primary = {m_rcFocusRect.red,
- m_rcFocusRect.green,
- m_rcFocusRect.blue,
- TRUE};
- PixelProps secondary = {m_rcFocusRect.red2,
- m_rcFocusRect.green2,
- m_rcFocusRect.blue2,
- m_rcFocusRect.bSecondaryColors};
- // Draw the rect into the pImage
- if (m_rcFocusRect.ulShape & DRAW_RECT)
- {
- StraightLine((void*)pImage,
- GETBITMAPPITCH(pImageInfo),
- pImageInfo->biBitCount,
- pImageRect->right-pImageRect->left,
- pImageRect->bottom-pImageRect->top,
- m_rcFocusRect.rcFocus.left, m_rcFocusRect.rcFocus.top,
- m_rcFocusRect.rcFocus.right, m_rcFocusRect.rcFocus.top,
- (UINT8)m_rcFocusRect.ulLineWidth,
- &primary, &secondary,
- nStyle,
- pCustomPattern, m_rcFocusRect.ulCustomEntries);
- StraightLine((void*)pImage,
- GETBITMAPPITCH(pImageInfo),
- pImageInfo->biBitCount,
- pImageRect->right-pImageRect->left,
- pImageRect->bottom-pImageRect->top,
- m_rcFocusRect.rcFocus.right, m_rcFocusRect.rcFocus.top,
- m_rcFocusRect.rcFocus.right, m_rcFocusRect.rcFocus.bottom,
- (UINT8)m_rcFocusRect.ulLineWidth,
- &primary, &secondary,
- nStyle,
- pCustomPattern, m_rcFocusRect.ulCustomEntries);
- StraightLine((void*)pImage,
- GETBITMAPPITCH(pImageInfo),
- pImageInfo->biBitCount,
- pImageRect->right-pImageRect->left,
- pImageRect->bottom-pImageRect->top,
- m_rcFocusRect.rcFocus.right, m_rcFocusRect.rcFocus.bottom,
- m_rcFocusRect.rcFocus.left, m_rcFocusRect.rcFocus.bottom,
- (UINT8)m_rcFocusRect.ulLineWidth,
- &primary, &secondary,
- nStyle,
- pCustomPattern, m_rcFocusRect.ulCustomEntries);
- StraightLine((void*)pImage,
- GETBITMAPPITCH(pImageInfo),
- pImageInfo->biBitCount,
- pImageRect->right-pImageRect->left,
- pImageRect->bottom-pImageRect->top,
- m_rcFocusRect.rcFocus.left, m_rcFocusRect.rcFocus.bottom,
- m_rcFocusRect.rcFocus.left, m_rcFocusRect.rcFocus.top,
- (UINT8)m_rcFocusRect.ulLineWidth,
- &primary, &secondary,
- nStyle,
- pCustomPattern, m_rcFocusRect.ulCustomEntries);
- }
- else if (m_rcFocusRect.ulShape & DRAW_ELLIPSE)
- {
- }
- else if (m_rcFocusRect.ulShape & DRAW_POLYGON)
- {
- UINT32 i=0;
- for (i=0; i<m_rcFocusRect.polygon.ulFocusPoints-1; i++)
- {
- StraightLine((void*)pImage,
- GETBITMAPPITCH(pImageInfo),
- pImageInfo->biBitCount,
- pImageRect->right-pImageRect->left,
- pImageRect->bottom-pImageRect->top,
- m_rcFocusRect.polygon.pFocusPoints[i].x, m_rcFocusRect.polygon.pFocusPoints[i].y,
- m_rcFocusRect.polygon.pFocusPoints[i+1].x, m_rcFocusRect.polygon.pFocusPoints[i+1].y,
- (UINT8)m_rcFocusRect.ulLineWidth,
- &primary, &secondary,
- nStyle,
- pCustomPattern, m_rcFocusRect.ulCustomEntries);
- }
- StraightLine((void*)pImage,
- GETBITMAPPITCH(pImageInfo),
- pImageInfo->biBitCount,
- pImageRect->right-pImageRect->left,
- pImageRect->bottom-pImageRect->top,
- m_rcFocusRect.polygon.pFocusPoints[i].x, m_rcFocusRect.polygon.pFocusPoints[i].y,
- m_rcFocusRect.polygon.pFocusPoints[0].x, m_rcFocusRect.polygon.pFocusPoints[0].y,
- (UINT8)m_rcFocusRect.ulLineWidth,
- &primary, &secondary,
- nStyle,
- pCustomPattern, m_rcFocusRect.ulCustomEntries);
- }
- }
- /************************************************************************
- ************************************************************************
- * INTERNAL HELPER FUNCTIONS
- ************************************************************************
- ************************************************************************/
- void CHXBaseSite::SetXSliderRange(INT32 range)
- {
- _TryCreateXSlider();
- if (m_XSliderRange != range)
- {
- if (m_XSliderRange)
- {
- m_XSliderPos = m_XSliderPos * range / m_XSliderRange;
- }
- HXxSize parentSize;
- memset(&parentSize, 0, sizeof(HXxSize));
- if (m_pParentSite)
- {
- m_pParentSite->GetSize(parentSize);
- }
- m_XSliderRange = range;
- _SetXSliderValues(m_XSliderRange, parentSize.cx);
- }
- }
- INT32 CHXBaseSite::GetXSliderRange()
- {
- return m_XSliderRange;
- }
- INT32 CHXBaseSite::GetYSliderRange()
- {
- return m_YSliderRange;
- }
- void CHXBaseSite::SetYSliderRange(INT32 range)
- {
- _TryCreateYSlider();
- if (m_YSliderRange != range)
- {
- if (m_YSliderRange)
- {
- m_YSliderPos = m_YSliderPos * range / m_YSliderRange;
- }
- HXxSize parentSize;
- memset(&parentSize, 0, sizeof(HXxSize));
- if (m_pParentSite)
- {
- m_pParentSite->GetSize(parentSize);
- }
- m_YSliderRange = range;
- _SetYSliderValues(m_YSliderRange, parentSize.cy);
- }
- }
- INT32 CHXBaseSite::GetXSliderPos()
- {
- return m_XSliderPos;
- }
- INT32 CHXBaseSite::GetYSliderPos()
- {
- return m_YSliderPos;
- }
- INT32 CHXBaseSite::GetSliderWidth()
- {
- INT32 Width, Height;
- _GetSystemSizeOfSliders(&Width, &Height);
- return Width;
- }
- INT32 CHXBaseSite::GetSliderHeight()
- {
- INT32 Width, Height;
- _GetSystemSizeOfSliders(&Width, &Height);
- return Height;
- }
- // XXXAH this function is pretty poorly named and I want to change it.
- // however in keeping with the idea behind this conversion (namely CHANGE
- // NOTHING on windows), I will leave it in here for the moment.
- void CHXBaseSite::GetWindowRect(HXxRect* pRect)
- {
- if (m_RegionForMouse)
- {
- pRect->left = m_Region->extents.x1;
- pRect->top = m_Region->extents.y1;
- pRect->right = m_Region->extents.x2;
- pRect->bottom = m_Region->extents.y2;
- }
- }
- void CHXBaseSite::GetExtentsWithoutChildren(HXxRect* pRect)
- {
- if (m_RegionWithoutChildren)
- {
- pRect->left = m_RegionWithoutChildren->extents.x1;
- pRect->top = m_RegionWithoutChildren->extents.y1;
- pRect->right = m_RegionWithoutChildren->extents.x2;
- pRect->bottom = m_RegionWithoutChildren->extents.y2;
- }
- }
- void CHXBaseSite::RecursiveSizeSliders()
- {
- SizeSliders();
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->RecursiveSizeSliders();
- }
- }
- void CHXBaseSite::SizeSliders()
- {
- //Size the X slider 1st.
- INT32 width;
- INT32 height;
- _GetSystemSizeOfSliders(&width, &height);
- // The size of the SITE is the size of the bounding rect of the
- // region.
- HXxRect boundRect;
- memset( &boundRect, 0, sizeof( HXxRect ) );
- if (m_pParentSite)
- {
- m_pParentSite->GetExtentsWithoutChildren(&boundRect);
- }
- else
- {
- GetWindowRect(&boundRect);
- }
- // XXXAH why am I using this function? Will Have to check later to
- // see why IHXSite2::IsSiteVisible is insufficient. AHH I now
- // remember this is due to a bug with the sliders appearing on TOP
- // of the buffering animation.
- BOOL siteVisible = _IsWindowVisible();
- /*
- * Modify boundRect by the screen offset.
- */
- HXxPoint screenOffset;
- if (m_pParentSite)
- {
- screenOffset = m_pParentSite->GetScreenOffset();
- }
- else
- {
- screenOffset = GetScreenOffset();
- }
- boundRect.left += screenOffset.x;
- boundRect.right += screenOffset.x;
- boundRect.top += screenOffset.y;
- boundRect.bottom += screenOffset.y;
- _ShowXSlider((siteVisible && m_bIsVisible) ? TRUE : FALSE);
- _MoveXSlider(boundRect.left, boundRect.bottom - height, boundRect.right - boundRect.left, height, TRUE);
- _ShowYSlider((siteVisible && m_bIsVisible) ? TRUE : FALSE);
- _MoveYSlider(boundRect.right - width, boundRect.top, width, boundRect.bottom - boundRect.top - (_DoesXSliderExist() ? height : 0), TRUE);
- // XXXMEH - checking siteVisible above prevents scroll bars
- // from appearing above the buffering animation logo. For datatypes
- // which ForceRedraw over and over, this is no problem. The scroll bars
- // just show up one blt late. However, most still image datatypes
- // just ForceRedraw once at the first timesync. So for those
- // datatypes, that fix is preventing the scroll bars from showing up.
- // So if m_bIsVisible is TRUE and siteVisible is FALSE (where we
- // *would* have turned the scrollbars on but were prevented by the
- // fact that the site was not yet visible), then we will set up
- // a callback to check again.
- if (m_bIsVisible && !siteVisible && m_bScrollingSite)
- {
- // Have we already scheduled a callback?
- if (!m_ScrollSiteCallbackHandle)
- {
- // Have we already created a ScrollSiteCallback
- if (!m_pScrollSiteCallback)
- {
- m_pScrollSiteCallback = new ScrollSiteCallback(this);
- }
- if (m_pScrollSiteCallback && m_pScheduler)
- {
- m_ScrollSiteCallbackHandle = m_pScheduler->RelativeEnter(m_pScrollSiteCallback, 20);
- }
- }
- }
- }
- void CHXBaseSite::FuncSizeSliders()
- {
- m_ScrollSiteCallbackHandle = 0;
- SizeSliders();
- }
- HX_RESULT CHXBaseSite::ConvertStringToXYDepth(const char* pszModeString, REF(INT32) x, REF(INT32) y, REF(INT32) depth)
- {
- HX_RESULT retVal = HXR_FAIL;
- int stringLength = strlen(pszModeString);
- char* pszTempString = new char[stringLength+1];
- memcpy(pszTempString, pszModeString, stringLength+1); /* Flawfinder: ignore */
- char* token = strtok( pszTempString, MODE_DESRIPTION_SEPS);
- if (!token)
- {
- goto cleanup;
- }
- x = atoi(token);
- token = strtok( NULL, MODE_DESRIPTION_SEPS);
- if (!token)
- {
- goto cleanup;
- }
- y = atoi(token);
- token = strtok( NULL, MODE_DESRIPTION_SEPS);
- if (!token)
- {
- goto cleanup;
- }
- depth = atoi(token);
- retVal = HXR_OK;
- cleanup:
- HX_VECTOR_DELETE(pszTempString);
- return retVal;
- }
- void CHXBaseSite::SetDisplayMode()
- {
- m_bSettingDisplayMode = TRUE;
- _TLSLock();
- // check to see if the top level client has set the resolution of
- // full screen. If not then we will stay in the same resolution.
- // if they did then we will will call DD and set the mode.
- IHXPreferences* pPreferences = NULL;
- IHXBuffer* pBuffer = NULL;
- char* pszModesToTest = NULL;
- char szBuffer[255]; /* Flawfinder: ignore */
- if (HXR_OK == m_pContext->QueryInterface(IID_IHXPreferences,(void**)&pPreferences))
- {
- strcpy(szBuffer, REGKEY_FULLSCREEN_DATA); /* Flawfinder: ignore */
- strcat(szBuffer, "\"); /* Flawfinder: ignore */
- strcat(szBuffer, REGKEY_FULLSCREEN_PREFERED_MODE); /* Flawfinder: ignore */
- pPreferences->ReadPref(szBuffer, pBuffer);
- INT32 x = 0;
- INT32 y = 0;
- INT32 depth = 0;
- if (pBuffer)
- {
- if (HXR_OK ==ConvertStringToXYDepth((char*)pBuffer->GetBuffer(), x, y, depth))
- {
- DestroySurfaces();
- if (zm_bInFullScreenTest)
- {
- m_pRootSurface->SetResolution(x, y, depth, m_pWindow ? m_pWindow->window : NULL);
- }
- else
- {
- void* pWindow = _GetContainingWindow();
- m_pRootSurface->SetResolution(x, y, depth, pWindow);
- }
- ReInitSurfaces();
- }
- HX_RELEASE(pBuffer);
- }
- HX_RELEASE(pPreferences);
- }
- m_bSettingDisplayMode = FALSE;
- _TLSUnlock();
- }
- //Not used in unix land.......
- BOOL CHXBaseSite::GenerateMouseLeaveMessage()
- {
- if (m_pMouseInSite)
- {
- void* pWindowHandle = _GetWindowWithCursor();
- // XXXAH this is different than the current implemenation!! XXXAH
- // But the current impementation has a bug in it!!
- //XXXgfw why do we test for GetWindow() and then use m_pWindow??
- HXxWindow* pWindow = GetWindow();
- if(pWindow && (pWindowHandle != pWindow->window))
- {
- HXxPoint oobPoint;
- oobPoint.x = -1;
- oobPoint.y = -1;
- HXxEvent event = {HX_MOUSE_LEAVE, m_pWindow ? m_pWindow->window : NULL, (void*)&oobPoint, 0, 0, FALSE};
- m_pMouseInSite->EventOccurred(&event);
- m_pMouseInSite = NULL;
- return TRUE;
- }
- }
- return FALSE;
- }
- void CHXBaseSite::CheckExposeEvents()
- {
- if (!m_pRootSurface)
- {
- m_bRepaintScheduled = FALSE;
- return;
- }
- if (!m_pParentSite)
- {
- m_pRootSurface->SetBltLock(TRUE);
- }
- if (m_bRepaintScheduled)
- {
- InternalForceRedraw();
- m_bRepaintScheduled = FALSE;
- }
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->CheckExposeEvents();
- }
- m_pVideoSurface->FillColorKey();
- m_pVideoSurface->UpdateDestRect();
- if (!m_pParentSite)
- {
- m_pRootSurface->SetBltLock(FALSE);
- }
- }
- BOOL CHXBaseSite::_TakesPartInAlphaChain()
- {
- BOOL retVal=FALSE;
- int nCID=-1;
- if( !IsSiteVisible() )
- return FALSE;
- if( m_pVideoSurface )
- nCID = GETBITMAPCOLOR(&(m_pVideoSurface->m_bmiLastBlt));
- //Current conditions to force conversion to ARGB and inclusion in
- //the alpha blending chain.
- //
- // 1) Native format is ARGB
- // 2) Has not blt'ed at least once (CID_UNKNOWN)
- // 3) m_bSiteNeverBlts type of regions (see through).
- // 4) _BlendedBordersActive() type. We must have ARGB to blend the borders.
- // 5) m_nEventSensitivity==SENSITIVITY_TRANSPARENT we need these to be part
- // of the alpha chain so that we can find the site that click belongs to.
- // 6) any site with a fade transition in effect.
- if(CID_ARGB32==nCID || CID_UNKNOWN==nCID || m_bSiteNeverBlts )
- // if(CID_ARGB32==nCID || m_bSiteNeverBlts )
- retVal = TRUE;
- else if( m_nEventSensitivity==SENSITIVITY_TRANSPARENT )
- retVal = TRUE;
- else if( _BlendedBordersActive() )
- retVal = TRUE;
- else if( m_fpTransitionEffect == Crossfade )
- retVal = TRUE;
- else if( m_fpTransitionEffect == FadeToColor )
- retVal = TRUE;
- else if( m_fpTransitionEffect == FadeFromColor )
- retVal = TRUE;
- return retVal;
- }
- BOOL CHXBaseSite::ComputeSubRects()
- {
- _TLSLock();
- BOOL retVal = TRUE;
- HXREGION* hTemp = NULL;
- HXREGION* hTemp2 = NULL;
- BOOL bRepaintMessage = TRUE;
- HXxSize size;
- HXxPoint* pPosition = NULL;
- HXxRect rectClientRect;
- LISTPOSITION pos = NULL;
- m_pVideoSurface->_RemoveYUVImageLists();
- if( m_pValues )
- {
- IHXBuffer* pBuf=NULL;
- m_bSiteNeverBlts=FALSE;
- m_pValues->GetPropertyCString( "SiteNeverBlts", pBuf );
- if( pBuf )
- {
- m_bSiteNeverBlts = atoi( (const char*)pBuf->GetBuffer() )==1;
- if( m_bSiteNeverBlts )
- {
- //Make these sites naturally transparent to events.
- m_nEventSensitivity = SENSITIVITY_TRANSPARENT;
- }
- HX_RELEASE(pBuf);
- }
- }
- if (m_Region)
- {
- hTemp2 = HXCreateRectRegion(0,0,0,0);
- HXUnionRegion(hTemp2, m_Region, hTemp2);
- HXDestroyRegion(m_Region);
- m_Region = NULL;
- HXDestroyRegion(m_RegionForMouse);
- m_RegionForMouse = NULL;
- }
- if (m_RegionWithoutChildren)
- {
- HXDestroyRegion(m_RegionWithoutChildren);
- m_RegionWithoutChildren = NULL;
- }
- rectClientRect.left = m_topleft.x;
- rectClientRect.right = m_topleft.x + m_size.cx;
- rectClientRect.top = m_topleft.y;
- rectClientRect.bottom = m_topleft.y + m_size.cy;
- if (IsSiteVisible())
- {
- m_RegionWithoutChildren = Transition(m_topleft.x, m_topleft.y,
- m_topleft.x + m_size.cx,
- m_topleft.y + m_size.cy,
- &m_TransitionBorderLines);
- if (m_pParentSite)
- m_pParentSite->BuildParnetClipping(m_RegionWithoutChildren,this);
- // subtract all of my children from my clipping region
- m_Region = HXCreateRectRegion(0,0,0,0);
- HXUnionRegion(m_Region, m_RegionWithoutChildren, m_Region);
- if (m_Region->numRects == 0)
- {
- retVal = FALSE;
- }
- else
- {
- pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*) m_ChildrenInZOrder.GetNext(pos);
- if (pSite->IsSiteVisible())
- {
- pPosition = pSite->GetOrigin();
- memcpy(&size, &pSite->m_size, sizeof(size)); /* Flawfinder: ignore */
- hTemp = pSite->Transition(pPosition->x, pPosition->y,
- pPosition->x + size.cx,
- pPosition->y + size.cy);
- HXSubtractRegion(m_Region, hTemp, m_Region);
- HXDestroyRegion(hTemp);
- hTemp = NULL;
- }
- }
- }
- }
- else
- {
- m_RegionWithoutChildren = HXCreateRectRegion(0,0,0,0);
- m_Region = HXCreateRectRegion(0,0,0,0);
- }
- // check to see if every destination new region and the
- // old region are the same.
- if (hTemp2)
- {
- if (HXEqualRegion( m_Region, hTemp2) &&
- m_rectOldClientRect.left == rectClientRect.left &&
- m_rectOldClientRect.right == rectClientRect.right &&
- m_rectOldClientRect.top == rectClientRect.top &&
- m_rectOldClientRect.bottom == rectClientRect.bottom)
- {
- bRepaintMessage = FALSE;
- }
- else
- {
- //We want to damage the old and new rects.
- // HXxRect pTmp = { m_topleft.x,
- // m_topleft.y,
- // m_topleft.x+m_size.cx,
- // m_topleft.y+m_size.cy};
- //XOR the old and new and damage it.
- // HXXorRegion( hTemp2, m_Region, hTemp2 );
- // m_pTopLevelSite->_RecursiveDamageRect( &pTmp );
- }
- }
- memcpy(&m_rectOldClientRect, &rectClientRect, sizeof(m_rectOldClientRect)); /* Flawfinder: ignore */
- HXDestroyRegion(hTemp2);
- hTemp2 = NULL;
- m_bRegionIsValid = TRUE;
- ////////////////////////////////////////////////////////
- // BEGIN ALPHA BLENDING WORK //
- ////////////////////////////////////////////////////////
- //for each sibling lowing in the Zorder than us, compute a
- //alpha region for it to blend with.
- //First, clean up the old.....
- _EmptyBlenderList();
- //Now make the new.......
- //First, the parent is a special case....
- if( m_pParentSite && IsSiteVisible() && _TakesPartInAlphaChain())
- {
- INT32 nZOrder = 0;
- INT32 nMyZOrder = m_lZOrder;
- CHXBaseSite* pParent = m_pParentSite;
- HXxPoint* pPosition = m_pParentSite->GetOrigin();
- HXREGION* pRegion =
- pParent->Transition( pPosition->x, pPosition->y,
- pPosition->x + pParent->m_size.cx,
- pPosition->y + pParent->m_size.cy);
- if(pRegion->numRects != 0)
- {
- pos = m_pParentSite->m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_pParentSite->m_ChildrenInZOrder.GetNext(pos);
- //All site before me in my parents list are of lower zorder by
- //default. We don't want to subtract ourselves.
- if( this == pSite )
- {
- break;
- }
- if(pSite->IsSiteVisible())
- {
- pPosition = pSite->GetOrigin();
- HXREGION* hTemp = pSite->Transition(pPosition->x, pPosition->y,
- pPosition->x + pSite->m_size.cx,
- pPosition->y + pSite->m_size.cy);
- HXSubtractRegion(pRegion, hTemp, pRegion);
- HXDestroyRegion(hTemp);
- hTemp = NULL;
- }
- }
- }
- //pRegion now has the region we need to intersect with.
- //XXXgfw, if you are seeing weird alpha problems try
- //using this region instead of the transition one below.
- // HXREGION* pMe = HXCreateRectRegion( m_topleft.x,
- // m_topleft.y,
- // m_size.cx, // !!! should be +m_topleft
- // m_size.cy // !!! should be +m_topleft
- // );
- HXREGION* pMe = Transition(m_topleft.x, m_topleft.y,
- m_topleft.x + m_size.cx,
- m_topleft.y + m_size.cy);
- HXIntersectRegion( pRegion, pMe, pRegion );
- HXDestroyRegion( pMe );
- //Don't delete the region if we save it in the map!
- BOOL bRegionNeedsDeleting = TRUE;
- if( !HXEmptyRegion(pRegion) )
- {
- //Add it to our region list that we alpha blend with only
- //if we are alpha blendable.
- if( _TakesPartInAlphaChain() )
- {
- // pRegion now contains our alpha blend region on our parent.
- // If our parent is a m_bSiteNeverBlts kind, then we will
- // can't alphablend with it, we need to see what alphablend
- // regions our parent has that intersect with us. Then, for
- // each one that does intersect us, we add it, and add
- // ourselves to that sites notifier list. We should NOT have
- // added our parent to that sites notifier list because it is
- // a m_bSiteNeverBlts.
- //
- // Terribly confusing what.
- // If you don't get it, listen to this:
- // http://www.dangermouse.org/sounds/what.wav
- if( !pParent->m_bSiteNeverBlts)
- {
- #if defined(_DEBUG) && 0
- VerifyNoDups( m_AlphaBlendSites, pRegion );
- #endif
- m_AlphaBlendSites.SetAt( pParent, pRegion );
- int nCID = GETBITMAPCOLOR(&(pParent->m_pVideoSurface->m_bmiLastBlt));
- bRegionNeedsDeleting = FALSE;
- //Add ourselves to that site's notifier list if only if we
- //are not a m_bSiteNeverBlts.
- if( !m_bSiteNeverBlts)
- pParent->_AlphaBlendAddNotifier(this);
- }
- else
- {
- //OK, go through the parents alpha regions and intersect..
- CHXMapPtrToPtr::Iterator ii = pParent->m_AlphaBlendSites.Begin();
- for ( ; ii != pParent->m_AlphaBlendSites.End(); ++ii)
- {
- HXREGION* pTmpReg = HXCreateRegion();
- HXIntersectRegion( pRegion, (HXREGION*)*ii, pTmpReg );
- if( !HXEmptyRegion(pTmpReg) )
- {
- //Add this region and a notifier if we need it.
- CHXBaseSite* pTmpSite = (CHXBaseSite*) ii.get_key();
- // See we already have a alphablend region with that
- // site. If so, union the two.
- void* pOrig = NULL;
- if(m_AlphaBlendSites.Lookup((void*)pTmpSite, pOrig ) )
- {
- //Must union it.
- HXUnionRegion( pTmpReg, (HXREGION*)pOrig, pTmpReg );
- HXDestroyRegion( (HXREGION*)pOrig );
- }
- #if defined(_DEBUG) && 0
- VerifyNoDups( m_AlphaBlendSites, pTmpReg );
- #endif
- m_AlphaBlendSites.SetAt( pTmpSite, pTmpReg );
- int nCID = GETBITMAPCOLOR(&(pTmpSite->m_pVideoSurface->m_bmiLastBlt));
- if( !m_bSiteNeverBlts )
- pTmpSite->_AlphaBlendAddNotifier(this);
- }
- else
- {
- //just clean up an empty region that isn't added to our map.
- HXDestroyRegion( pTmpReg );
- pTmpReg=NULL;
- }
- }
- }
- }
- //XXXgfw maybe do an AddRef on the site????
- }
- if( bRegionNeedsDeleting )
- {
- //just clean up an empty region that isn't added to our map.
- HXDestroyRegion(pRegion);
- pRegion=NULL;
- }
- //Now do all the children.....
- pos = m_pParentSite->m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_pParentSite->m_ChildrenInZOrder.GetNext(pos);
- if( this == pSite )
- {
- break;
- }
- pSite->AlphaBlendComputeSubRects(this);
- }
- }
- // OK, here is some real fun. If, we are a m_bSiteNeverBlts type of
- // site, then we must take our m_Region, intersect it with all of
- // our alphablend sites, and then add that result back into the
- // m_Region of the alphablend sibling. Because, since we aren't
- // drawing, someone needs to draw that part of the screen.
- if( m_bSiteNeverBlts )
- {
- CHXMapPtrToPtr::Iterator iter = m_AlphaBlendSites.Begin();
- for ( ; iter != m_AlphaBlendSites.End(); ++iter)
- {
- HXREGION* pTmpReg = HXCreateRegion();
- HXREGION* hTemp = NULL;
- HXxPoint* pPosition;
- HXxSize size;
- HXREGION* pAlphaReg = (HXREGION*)*iter;
- CHXBaseSite* pTmpSite = (CHXBaseSite*) iter.get_key();
- //Now remove all higher order siblings from this alpha region.
- HXUnionRegion( pTmpReg, pAlphaReg, pTmpReg );
- if( m_pParentSite )
- m_pParentSite->_RemoveHigherOrderSiblings(pTmpReg, this );
- // Get rid of all children of mine..
- pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- if(pSite->IsSiteVisible() )
- {
- memcpy(&size, &pSite->m_size, sizeof(HXxSize)); /* Flawfinder: ignore */
- pPosition = pSite->GetOrigin();
- hTemp = pSite->Transition(pPosition->x, pPosition->y,
- pPosition->x + size.cx,
- pPosition->y + size.cy);
- HXSubtractRegion(pTmpReg, hTemp, pTmpReg);
- HXDestroyRegion(hTemp);
- hTemp=NULL;
- }
- }
- if( !HXEmptyRegion(pTmpReg) )
- {
- //Add this back into the sites m_Region.
- HXUnionRegion(pTmpSite->m_Region, pTmpReg, pTmpSite->m_Region);
- }
- HXDestroyRegion(pTmpReg);
- }
- }
- ////////////////////////////////////////////////////////
- // END ALPHA BLENDING WORK //
- ////////////////////////////////////////////////////////
- // Now copy our visual region into a mouse/event region.
- m_RegionForMouse = HXCreateRegion();
- HXUnionRegion( m_RegionForMouse, m_Region, m_RegionForMouse);
- //If we have a parent site and a window then we must set our window
- //rgn to that specified in m_hClip
- m_topleft.x =0;
- m_topleft.y =0;
- GetAbsoluteCords(m_topleft);
- if(bRepaintMessage )
- {
- InternalForceRedraw();
- if (m_pVideoSurface)
- {
- m_pVideoSurface->FillColorKey();
- }
- }
- SizeSliders();
- _TLSUnlock();
- return TRUE;
- }
- void CHXBaseSite::BuildParnetClipping( HXREGION* hClip, CHXBaseSite* pChild)
- {
- HXREGION* hTemp = NULL;
- HXxPoint* pPosition = NULL;
- HXxSize size;
- BOOL bFound = FALSE;
- // subtract all of my children from my clipping region
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- //Keep in mind that all site before pChild have zorder less than
- //pChild and all sites after have a higher zorder.
- if( pChild == pSite )
- {
- bFound = TRUE;
- }
- if(bFound && pChild!=pSite && pSite->IsSiteVisible())
- {
- memcpy(&size, &pSite->m_size, sizeof(HXxSize)); /* Flawfinder: ignore */
- pPosition = pSite->GetOrigin();
- hTemp = pSite->Transition(pPosition->x, pPosition->y,
- pPosition->x + size.cx,
- pPosition->y + size.cy);
- HXSubtractRegion(hClip, hTemp, hClip);
- HXDestroyRegion(hTemp);
- hTemp=NULL;
- }
- }
- // now handle my clipping region
- // if my region is valid use that ...
- if (m_bRegionIsValid )
- {
- HXIntersectRegion(hClip, m_RegionWithoutChildren, hClip);
- }
- else
- {
- hTemp = Transition(m_topleft.x, m_topleft.y,
- m_topleft.x + m_size.cx,
- m_topleft.y + m_size.cy,
- &m_TransitionBorderLines);
- HXIntersectRegion(hClip, hTemp, hClip);
- HXDestroyRegion(hTemp);
- hTemp=NULL;
- if (m_pParentSite)
- m_pParentSite->BuildParnetClipping(hClip,this);
- }
- }
- BOOL CHXBaseSite::AreVideoControlsActive()
- {
- if (m_pParentSite)
- {
- return m_pParentSite->AreVideoControlsActive();
- }
- return m_fBrightness != DEF_BRIGHTNESS ||
- m_fContrast != DEF_CONTRAST ||
- m_fSharpness != DEF_SHARPNESS ||
- m_fHue != DEF_HUE ||
- m_fSaturation != DEF_SATURATION;
- }
- BOOL CHXBaseSite::_BordersActive()
- {
- return (m_TransitionBorderLines.m_nLines && m_nTransitionBorderWidth);
- }
- BOOL CHXBaseSite::_BlendedBordersActive()
- {
- return (m_TransitionBorderLines.m_nLines &&
- m_nTransitionBorderWidth &&
- m_bTransitionBlendBorder &&
- m_nTransitionState < 1000);
- }
- BOOL CHXBaseSite::_FadeTransitionActive()
- {
- return ( (m_fpTransitionEffect == Crossfade ||
- m_fpTransitionEffect == FadeToColor ||
- m_fpTransitionEffect == FadeFromColor)
- && m_nTransitionState<1000
- );
- }
- BOOL CHXBaseSite::_IsAlphaBlending()
- {
- return _BordersActive() ||
- _FadeTransitionActive() ||
- _TakesPartInAlphaChain() ||
- m_AlphaBlendNotifiers.GetCount() != 0 ||
- m_AlphaBlendSites.GetCount() != 0;
- }
- BOOL CHXBaseSite::IsHigherZOrderTranstitionActive()
- {
- BOOL bRet = FALSE;
- CHXMapPtrToPtr::Iterator iter = m_AlphaBlendNotifiers.Begin();
- for ( ; iter != m_AlphaBlendNotifiers.End(); ++iter)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)*iter;
- if (pSite->m_fpTransitionEffect != DefaultTransition &&
- pSite->m_nTransitionState > 0 &&
- pSite->m_nTransitionState < 1000 &&
- GETBITMAPCOLOR(&pSite->m_pVideoSurface->m_bmiLastBlt) == CID_ARGB32)
- {
- bRet = TRUE;
- break;
- }
- }
- return bRet;
- }
- ////////////////////////////////////////////////////////
- // BEGIN ALPHA BLENDING WORK //
- ////////////////////////////////////////////////////////
- void CHXBaseSite::_RemoveHigherOrderSiblings( HXREGION* hClip, CHXBaseSite* pChild)
- {
- HXREGION* hTemp = NULL;
- HXxPoint* pPosition = NULL;
- HXxSize size;
- BOOL bFound = FALSE;
- // Get rid of all higher zorder siblings from this region.
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- //Keep in mind that all site before pChild in this list are lower
- //zorder and all sites afer have higher zorders.
- if( pChild == pSite )
- {
- bFound = TRUE;
- }
- if(bFound && pChild!=pSite && pSite->IsSiteVisible() )
- {
- memcpy(&size, &pSite->m_size, sizeof(HXxSize)); /* Flawfinder: ignore */
- pPosition = pSite->GetOrigin();
- hTemp = pSite->Transition(pPosition->x, pPosition->y,
- pPosition->x + size.cx,
- pPosition->y + size.cy);
- HXSubtractRegion(hClip, hTemp, hClip);
- HXDestroyRegion(hTemp);
- hTemp=NULL;
- }
- }
- if( m_pParentSite )
- m_pParentSite->_RemoveHigherOrderSiblings( hClip, this );
- }
- void CHXBaseSite::AlphaBlendComputeSubRects(CHXBaseSite* pIgnoredSite)
- {
- HXREGION* hTemp = NULL;
- HXxSize size;
- HXxPoint* pPosition = NULL;
- HXREGION* pReturn = NULL;
- LISTPOSITION pos = NULL;
- HX_ASSERT( pIgnoredSite != this );
- if( pIgnoredSite == this )
- return;
- if( pIgnoredSite && !pIgnoredSite->_TakesPartInAlphaChain() )
- return;
- if(IsSiteVisible())
- {
- pReturn = Transition(m_topleft.x, m_topleft.y,
- m_topleft.x + m_size.cx,
- m_topleft.y + m_size.cy,
- &m_TransitionBorderLines);
- if(m_pParentSite)
- {
- m_pParentSite->AlphaBlendBuildParnetClipping( pReturn, this, pIgnoredSite );
- }
- // subtract all of my children from my clipping region
- if( pReturn->numRects != 0 )
- {
- pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- if(pSite->IsSiteVisible())
- {
- pPosition = pSite->GetOrigin();
- memcpy(&size, &pSite->m_size, sizeof(size)); /* Flawfinder: ignore */
- hTemp = pSite->Transition(pPosition->x, pPosition->y,
- pPosition->x + size.cx,
- pPosition->y + size.cy);
- HXSubtractRegion(pReturn, hTemp, pReturn);
- HXDestroyRegion(hTemp);
- hTemp = NULL;
- }
- }
- }
- }
- //Now we have an alpha blend region. Add it to the master sites
- //map if we overlap it at all.
- BOOL regionNeedsDeleting = TRUE;
- if( pReturn && !HXEmptyRegion( pReturn ) )
- {
- HXxPoint* pPosition = pIgnoredSite->GetOrigin();
- HXxSize* pSize = &(pIgnoredSite->m_size);
- HXREGION* pTmp = pIgnoredSite->Transition(pPosition->x,
- pPosition->y,
- pPosition->x+pSize->cx,
- pPosition->y+pSize->cy);
- //We must remove any overlapping NON-ARGB regions. Higher order
- //siblings and chilren....
- pos = pIgnoredSite->m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite2 =
- (CHXBaseSite*)(pIgnoredSite->m_ChildrenInZOrder.GetNext(pos));
- if(pSite2->IsSiteVisible() && !pSite2->_IsAlphaBlending())
- {
- pPosition = pSite2->GetOrigin();
- memcpy(&size, &pSite2->m_size, sizeof(size)); /* Flawfinder: ignore */
- hTemp = pSite2->Transition(pPosition->x, pPosition->y,
- pPosition->x + size.cx,
- pPosition->y + size.cy);
- HXSubtractRegion(pReturn, hTemp, pReturn);
- HXDestroyRegion(hTemp);
- hTemp = NULL;
- }
- }
- HXIntersectRegion( pReturn, pTmp, pReturn );
- HXDestroyRegion( pTmp );
- if ( !HXEmptyRegion( pReturn ) )
- {
- //Add it to our region list that we alpha blend with only
- //if we are alpha blendable.
- if( pIgnoredSite && pIgnoredSite->_TakesPartInAlphaChain() )
- {
- // pRetrun now contains our alpha blend region on
- // ourselves. If we are a m_bSiteNeverBlts kind, then we
- // don't want the ignored site to alphablend with us, we
- // need to see what alphablend regions we have that
- // intersect with the ignored site. Then, for each one
- // that does intersect, we add it, and add the ignored
- // site to our notifier list. We should NOT have added
- // ourselves to that sites notifier list because it is a
- // m_bSiteNeverBlts.
- //
- // Terribly confusing what.
- // If you don't get it, listen to this:
- // http://www.dangermouse.org/sounds/what.wav
- if( !m_bSiteNeverBlts)
- {
- //Add this to our list of regions we alpha blend with.
- //XXXgfw addref the site???
- #if defined(_DEBUG) && 0
- VerifyNoDups( pIgnoredSite->m_AlphaBlendSites, pReturn );
- #endif
- pIgnoredSite->m_AlphaBlendSites.SetAt( this, pReturn );
- int nCID = GETBITMAPCOLOR(&(m_pVideoSurface->m_bmiLastBlt));
- regionNeedsDeleting = FALSE;
- //Add the ignored site to our site's notifier list. Do this
- //only if the ignored site isn't m_bSiteNeverBlts type.
- if( !(pIgnoredSite->m_bSiteNeverBlts) )
- _AlphaBlendAddNotifier(pIgnoredSite);
- }
- else
- {
- //OK, go through the alpha regions and intersect..
- CHXMapPtrToPtr::Iterator ii = m_AlphaBlendSites.Begin();
- for ( ; ii != m_AlphaBlendSites.End(); ++ii)
- {
- HXREGION* pTmpReg = HXCreateRegion();
- HXIntersectRegion( pReturn, (HXREGION*)*ii, pTmpReg );
- if( !HXEmptyRegion(pTmpReg) )
- {
- //Add this region and a notifier if we need it.
- CHXBaseSite* pTmpSite = (CHXBaseSite*) ii.get_key();
- // See we already have a alphablend region with that
- // site. If so, union the two.
- void* pOrig = NULL;
- if(pIgnoredSite->m_AlphaBlendSites.Lookup((void*)pTmpSite, pOrig ) )
- {
- //Must union it.
- HXUnionRegion( pTmpReg, (HXREGION*)pOrig, pTmpReg );
- HXDestroyRegion( (HXREGION*)pOrig );
- }
- #if defined(_DEBUG) && 0
- VerifyNoDups( pIgnoredSite->m_AlphaBlendSites, pTmpReg );
- #endif
- pIgnoredSite->m_AlphaBlendSites.SetAt( pTmpSite, pTmpReg );
- int nCID = GETBITMAPCOLOR(&(pTmpSite->m_pVideoSurface->m_bmiLastBlt));
- if( !pIgnoredSite->m_bSiteNeverBlts )
- _AlphaBlendAddNotifier(pIgnoredSite);
- }
- else
- {
- //just clean up an empty region that isn't added to our map.
- HXDestroyRegion( pTmpReg );
- pTmpReg=NULL;
- }
- }
- }
- }
- }
- }
- if( pReturn && regionNeedsDeleting )
- {
- HXDestroyRegion(pReturn);
- pReturn=NULL;
- }
- //Now do all of our children too......
- pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->AlphaBlendComputeSubRects( pIgnoredSite );
- }
- }
- void CHXBaseSite::AlphaBlendBuildParnetClipping( HXREGION* hClip,
- CHXBaseSite* pChild,
- CHXBaseSite* pIgnoredSite
- )
- {
- HXREGION* hTemp = NULL;
- HXxPoint* pPosition;
- HXxSize size;
- BOOL bIgnoreSiteIsSibling = FALSE;
- LISTPOSITION pos = NULL;
- BOOL bFoundChild = FALSE;
- BOOL bFoundIgnored = FALSE;
- //Is the ignored site a sibling of ours? If not, ignore its z
- //order.
- if( pIgnoredSite->m_pParentSite == this )
- {
- bIgnoreSiteIsSibling = TRUE;
- }
- // subtract all of my children from my clipping region
- pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- if( pSite == pChild )
- {
- //Now all sites in this list will be of higher Zorder
- bFoundChild = TRUE;
- }
- else if( pSite == pIgnoredSite )
- {
- //Now, all sites in this list will be higher than the
- //ignored.
- bFoundIgnored = TRUE;
- }
- if( bFoundChild && pSite!=pChild &&
- ((!bFoundIgnored ) || !bIgnoreSiteIsSibling) &&
- (pSite->IsSiteVisible())
- )
- {
- memcpy(&size, &pSite->m_size, sizeof(HXxSize)); /* Flawfinder: ignore */
- pPosition = pSite->GetOrigin();
- hTemp = pSite->Transition(pPosition->x, pPosition->y,
- pPosition->x + size.cx,
- pPosition->y + size.cy);
- HXSubtractRegion(hClip, hTemp, hClip);
- HXDestroyRegion(hTemp);
- hTemp=NULL;
- }
- }
- hTemp = Transition(m_topleft.x, m_topleft.y,
- m_topleft.x + m_size.cx,
- m_topleft.y + m_size.cy);
- HXIntersectRegion(hClip, hTemp, hClip);
- HXDestroyRegion(hTemp);
- hTemp=NULL;
- if (m_pParentSite)
- m_pParentSite->AlphaBlendBuildParnetClipping( (HXREGION*)hClip,
- (CHXBaseSite*)this,
- (CHXBaseSite*)pIgnoredSite);
- }
- ////////////////////////////////////////////////////////
- // END ALPHA BLENDING WORK //
- ////////////////////////////////////////////////////////
- void CHXBaseSite::UpdateModes()
- {
- INT32 nNumModes = 0;
- CModesDesc* pModesDesc = 0;
- m_pRootSurface->GetDisplayModes(pModesDesc, &nNumModes);
- pModesDesc = new CModesDesc[nNumModes ];
- m_pRootSurface->GetDisplayModes(pModesDesc, &nNumModes);
- for(INT32 i=0; i<nNumModes; i++)
- {
- if (pModesDesc[i].m_nWidth>= 320 && pModesDesc[i].m_nHeight>=200 && pModesDesc[i].m_nBitCount>=8)
- {
- if (!DoesPrefExist(pModesDesc[i].m_nWidth, pModesDesc[i].m_nHeight, pModesDesc[i].m_nBitCount))
- {
- UpdatePrefs(pModesDesc[i].m_nWidth, pModesDesc[i].m_nHeight, pModesDesc[i].m_nBitCount, 0, FALSE, FALSE);
- }
- }
- }
- HX_VECTOR_DELETE(pModesDesc);
- }
- BOOL CHXBaseSite::DoesPrefExist(INT32 resolutionX, INT32 resolutionY, INT32 colorDepth)
- {
- char szNameBuffer[255]; /* Flawfinder: ignore */
- IHXBuffer* pBuffer = NULL;
- IHXPreferences* pPreferences = NULL;
- BOOL bFound = FALSE;
- if (HXR_OK == m_pContext->QueryInterface(IID_IHXPreferences, (void**)&pPreferences))
- {
- sprintf(szNameBuffer, "%s\%s\%dx%dx%d", /* Flawfinder: ignore */
- REGKEY_FULLSCREEN_DATA,
- REGKEY_FULLSCREEN_AVAILIABLE_MODES,
- resolutionX,
- resolutionY,
- colorDepth);
- if (HXR_OK == pPreferences->ReadPref(szNameBuffer, pBuffer))
- {
- bFound = TRUE;
- HX_RELEASE(pBuffer);
- }
- }
- HX_RELEASE(pPreferences);
- return bFound;
- }
- void CHXBaseSite::UpdatePrefs(INT32 resolutionX, INT32 resolutionY, INT32 colorDepth, ULONG32 ulBltTime, BOOL bPassed, BOOL bTested)
- {
- char szNameBuffer[255]; /* Flawfinder: ignore */
- IHXBuffer* pBuffer = NULL;
- IHXPreferences* pPreferences = NULL;
- if (HXR_OK == m_pContext->QueryInterface(IID_IHXPreferences, (void**)&pPreferences))
- {
- sprintf(szNameBuffer, "%s\%s\%dx%dx%d", /* Flawfinder: ignore */
- REGKEY_FULLSCREEN_DATA,
- REGKEY_FULLSCREEN_AVAILIABLE_MODES,
- resolutionX,
- resolutionY,
- colorDepth);
- pBuffer = new CHXBuffer();
- pBuffer->AddRef();
- char szTempBuffer[255]; /* Flawfinder: ignore */
- strcpy(szTempBuffer, szNameBuffer); /* Flawfinder: ignore */
- strcat(szTempBuffer, "\"); /* Flawfinder: ignore */
- strcat(szTempBuffer, REGKEY_TESTED); /* Flawfinder: ignore */
- if (bTested)
- {
- pBuffer->Set((const unsigned char*) "1", 2);
- }
- else
- {
- pBuffer->Set((const unsigned char*) "0", 2);
- }
- pPreferences->WritePref(szTempBuffer, pBuffer);
- strcpy(szTempBuffer, szNameBuffer); /* Flawfinder: ignore */
- strcat(szTempBuffer, "\"); /* Flawfinder: ignore */
- strcat(szTempBuffer, REGKEY_BLT_TIME); /* Flawfinder: ignore */
- char szNumberBuffer[20]; /* Flawfinder: ignore */
- sprintf( szNumberBuffer, "%d", ulBltTime ); /* Flawfinder: ignore */
- //itoa(ulBltTime, szNumberBuffer, 10);
- pBuffer->Set((const unsigned char*) szNumberBuffer, strlen(szNumberBuffer)+1);
- pPreferences->WritePref(szTempBuffer, pBuffer);
- strcpy(szTempBuffer, szNameBuffer); /* Flawfinder: ignore */
- strcat(szTempBuffer, "\"); /* Flawfinder: ignore */
- strcat(szTempBuffer, REGKEY_PASS); /* Flawfinder: ignore */
- if (bPassed)
- {
- pBuffer->Set((const unsigned char*) "1", 2);
- }
- else
- {
- pBuffer->Set((const unsigned char*) "0", 2);
- }
- pPreferences->WritePref(szTempBuffer, pBuffer);
- HX_RELEASE(pBuffer);
- }
- HX_RELEASE(pPreferences);
- }
- void CHXBaseSite::ScheduleCallback(INT32 nWhichCallback,
- INT32 nMilliseconds,
- BOOL bOverrideCompositionMode)
- {
- HX_ASSERT(m_pTopLevelSite == this);
- if( IsCompositionMode() && nWhichCallback!=MOUSE && !bOverrideCompositionMode )
- {
- return;
- }
- switch (nWhichCallback)
- {
- case REPAINT:
- if (m_bProcessRepaint)
- return;
- m_bProcessRepaint = TRUE;
- break;
- case CLIP:
- if (m_bRecomputeClipScheduled)
- return;
- m_bRecomputeClipScheduled = TRUE;
- break;
- case REDRAW_ALL:
- if (m_bForceRedrawNeeded)
- return;
- m_bForceRedrawNeeded = TRUE;
- break;
- case MOUSE:
- if (m_CallbackHandle)
- return;
- break;
- case MOVE:
- _TLSLock();
- /*
- * Site moving used to take an X, Y parameter, but since we changed it to
- * go to GDI mode, that is no longer relevant.
- */
- SiteMoving(0, 0);
- m_nLastMoveTime = HX_GET_TICKCOUNT();
- ScheduleCallback(MOUSE, 100);
- _TLSUnlock();
- return;
- default:
- HX_ASSERT(0);
- break;
- }
- if (m_pScheduler)
- {
- if (m_CallbackHandle)
- {
- m_pScheduler->Remove(m_CallbackHandle);
- m_CallbackHandle = 0;
- }
- m_CallbackHandle = m_pScheduler->RelativeEnter(m_pCallback, nMilliseconds);
- }
- return;
- }
- CBaseRootSurface* CHXBaseSite::GetRootSurface()
- {
- return m_pRootSurface;
- }
- BOOL CHXBaseSite::IsPointInClippingRegion(HXxPoint* pPoint)
- {
- return ::HXPointInRegion( m_RegionForMouse, pPoint->x, pPoint->y );
- }
- void
- CHXBaseSite::SiteNotMoving()
- {
- #if 1
- m_bMoving = FALSE;
- #else
- m_pVideoSurface->ForceGDIMode(FALSE);
- #endif
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pChildSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pChildSite->SiteNotMoving();
- }
- }
- void CHXBaseSite::ColorConverterRequest(int CIDIn, int CIDOut, BOOL bFoundConverter)
- {
- if (m_pTopLevelSite)
- m_pTopLevelSite->InternalColorConverterRequest(CIDIn, CIDOut, bFoundConverter, this);
- }
- void CHXBaseSite::InternalColorConverterRequest(int CIDIn, int CIDOut, BOOL bFoundConverter, CHXBaseSite* pSite)
- {
- int* pCIDs;
- BOOL bSchedule = FALSE;
- IHXSite *pISite = (IHXSite*)pSite;
- if (!bFoundConverter)
- {
- /*
- * 1st wins. If there is already an upgrade request for this
- * site, then add no more.
- */
- if (!m_upgradeMap.Lookup((void*) pISite, (void*&) pCIDs))
- {
- pCIDs = new int[2];
- pCIDs[0] = CIDIn;
- pCIDs[1] = CIDOut;
- m_upgradeMap.SetAt((void*)pISite, (void*)pCIDs);
- if (m_pScheduler)
- {
- if (m_CallbackHandle)
- {
- m_pScheduler->Remove(m_CallbackHandle);
- m_CallbackHandle = 0;
- }
- m_CallbackHandle = m_pScheduler->RelativeEnter(m_pCallback, 0);
- }
- m_bScheduleUpgrade = TRUE;
- }
- }
- else
- {
- if (m_upgradeMap.Lookup((void*) pISite, (void*&) pCIDs))
- {
- HX_DELETE(pCIDs);
- m_upgradeMap.Remove((void*) pISite);
- if (!m_upgradeMap.GetCount())
- {
- m_bScheduleUpgrade = FALSE;
- }
- }
- }
- }
- void CHXBaseSite::ScheduleUpgrade()
- {
- /*
- * We currently take the head of the list and upgrade that request
- * and forget about all of the rest within the list.
- */
- IHXSite* pSite = NULL;
- int* pCIDs;
- if (m_upgradeMap.GetCount())
- {
- POSITION pos = m_upgradeMap.GetStartPosition();
- m_upgradeMap.GetNextAssoc(pos, (void*&)pSite, (void*&) pCIDs);
- InternalScheduleUpgrade(pCIDs[0], pCIDs[1], pSite);
- HX_VECTOR_DELETE(pCIDs);
- while(pos)
- {
- m_upgradeMap.GetNextAssoc(pos, (void*&)pSite, (void*&) pCIDs);
- HX_VECTOR_DELETE(pCIDs);
- }
- m_upgradeMap.RemoveAll();
- }
- m_bScheduleUpgrade = FALSE;
- }
- void CHXBaseSite::InternalScheduleUpgrade(UINT32 CIDIn, UINT32 CIDOut, IHXSite* pSite)
- {
- /*
- * 1st we have to find the player to which we are attached.
- *
- * We will use two methods to find out who we are attached to.
- * 1. We will QI for SiteManager2 and iterate over the sites to see
- * if we are in the list.
- * 2. If we have only one player we will use that one!
- * 3. And we'll use the 1st player if we can't find anything.
- */
- IHXClientEngine* pEngine = NULL;
- IHXSite* pIterationSite = NULL;
- IHXBuffer* pBuffer = NULL;
- IUnknown* pUnknown = NULL;
- IHXSiteManager2* pSiteManager2 = NULL;
- UINT16 nPlayerCount;
- UINT32 index;
- UINT32 index2;
- UINT32 nNumSites;
- m_pContext->QueryInterface(IID_IHXClientEngine, (void**)&pEngine);
- if (!pEngine)
- goto cleanup;
- nPlayerCount = pEngine->GetPlayerCount();
- /*
- * Do we only have one player? If so, case solved!
- */
- if (nPlayerCount == 1)
- {
- pEngine->GetPlayer(0, pUnknown);
- goto playerFound;
- }
- else
- {
- for(index = 0; index< nPlayerCount; index++)
- {
- pEngine->GetPlayer((UINT16) index, pUnknown);
- pUnknown->QueryInterface(IID_IHXSiteManager2, (void**) &pSiteManager2);
- if (pSiteManager2)
- {
- pSiteManager2->GetNumberOfSites(nNumSites);
- for(index2 = 0; index2< nNumSites; index2++)
- {
- pSiteManager2->GetSiteAt(index2, pIterationSite);
- if (pSite == pIterationSite)
- {
- /*
- * We have a winner
- */
- HX_RELEASE(pSiteManager2);
- goto playerFound;
- }
- }
- }
- HX_RELEASE(pSiteManager2);
- HX_RELEASE(pUnknown);
- }
- }
- pEngine->GetPlayer(0, pUnknown);
- playerFound:
- // Auto download of color converter
- AddToAutoUpgradeCollection("colo", pUnknown);
- cleanup:
- HX_RELEASE(pUnknown);
- HX_RELEASE(pBuffer);
- HX_RELEASE(pEngine);
- }
- void CHXBaseSite::SetEvent(REF(HXxEvent) theEvent, ULONG32 event, void* window, void* param1, void* param2)
- {
- theEvent.event = event;
- theEvent.window = window;
- theEvent.param1 = param1;
- theEvent.param2 = param2;
- theEvent.result = 0;
- theEvent.handled = FALSE;
- }
- void CHXBaseSite::CheckDisplayMode(void* hdc)
- {
- BOOL bCreatedDC = FALSE;
- if (m_pTopLevelSite == this && !zm_bInFullScreenTest)
- {
- if (!m_bSettingDisplayMode)
- {
- UINT16 newBitsPerPixel, newHozRes, newVertRes;
- _GetDeviceCaps(hdc, newBitsPerPixel, newHozRes, newVertRes);
- if (m_nOldBitsPerPixel != newBitsPerPixel || newHozRes != m_nOldHorzRes || newVertRes != m_nOldVertRes)
- {
- m_nOldBitsPerPixel = newBitsPerPixel;
- m_nOldHorzRes = newHozRes;
- m_nOldVertRes = newVertRes;
- ChangeResolution();
- }
- }
- }
- }
- void CHXBaseSite::ChangeResolution()
- {
- if( this==m_pTopLevelSite &&
- m_pRootSurface &&
- m_pRootSurface->_OptimizedSurfaceOpened())
- {
- DestroySurfaces();
- /// XXXAH Uhm, I think I should be chaning the resolution here ....
- _ReInitPrimarySurface();
- ReInitSurfaces();
- }
- }
- void
- CHXBaseSite::DestroySurfaces()
- {
- if (m_pVideoSurface)
- {
- m_pVideoSurface->DestroySurfaces();
- }
- if (m_pRootSurface)
- {
- m_pRootSurface->DestroySurfaces();
- }
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->DestroySurfaces();
- }
- }
- void CHXBaseSite::LockBlitters()
- {
- if (m_pVideoSurface)
- {
- m_pVideoSurface->_LockBlitter();
- }
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->LockBlitters();
- }
- }
- void CHXBaseSite::UnlockBlitters()
- {
- if (m_pVideoSurface)
- {
- m_pVideoSurface->_UnlockBlitter();
- }
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->UnlockBlitters();
- }
- }
- void CHXBaseSite::FlushSurfaces()
- {
- if (m_pVideoSurface)
- {
- m_pVideoSurface->_FlushSurfaces();
- }
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->FlushSurfaces();
- }
- }
- void CHXBaseSite::DisableColorControls(float &fBrightness,
- float &fContrast,
- float &fSaturation,
- float &fHue)
- {
- if (m_pParentSite)
- {
- m_pParentSite->DisableColorControls(fBrightness,
- fContrast,
- fSaturation,
- fHue);
- return;
- }
- m_fHue = 0;
- m_fSaturation = 0;
- m_fContrast = 0;
- m_fBrightness = 0;
- }
- void CHXBaseSite::EnableColorControls(float fBrightness,
- float fContrast,
- float fSaturation,
- float fHue)
- {
- if (m_pParentSite)
- {
- m_pParentSite->EnableColorControls(fBrightness,
- fContrast,
- fSaturation,
- fHue);
- return;
- }
- m_fHue = fHue;
- m_fSaturation = fSaturation;
- m_fContrast = fContrast;
- m_fBrightness = fBrightness;
- }
- void CHXBaseSite::ReInitSurfaces()
- {
- if (m_pVideoSurface)
- {
- m_pVideoSurface->ReInitSurfaces();
- }
- if (m_pRootSurface)
- {
- m_pRootSurface->ReInitSurfaces();
- }
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->ReInitSurfaces();
- }
- }
- void CHXBaseSite::_EmptyBlenderList()
- {
- if( m_pTopLevelSite && m_pTopLevelSite->m_pMutex )
- _TLSLock();
- CHXMapPtrToPtr::Iterator iter = m_AlphaBlendSites.Begin();
- for ( ; iter != m_AlphaBlendSites.End(); ++iter)
- {
- HXREGION* pTmp = (HXREGION*)*iter;
- HXDestroyRegion( pTmp );
- pTmp = NULL;
- }
- m_AlphaBlendSites.RemoveAll();
- if( m_pTopLevelSite && m_pTopLevelSite->m_pMutex )
- _TLSUnlock();
- }
- void CHXBaseSite::_EmptyNotifierList()
- {
- if( m_pTopLevelSite && m_pTopLevelSite->m_pMutex )
- _TLSLock();
- m_bUsingList = FALSE;
- CHXMapPtrToPtr::Iterator iter = m_AlphaBlendNotifiers.Begin();
- for ( ; iter != m_AlphaBlendNotifiers.End(); ++iter)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)*iter;
- HX_RELEASE( pSite );
- }
- m_AlphaBlendNotifiers.RemoveAll();
- m_bUsingList = FALSE;
- if( m_pTopLevelSite && m_pTopLevelSite->m_pMutex )
- _TLSUnlock();
- }
- void CHXBaseSite::_AlphaBlendAddNotifier(CHXBaseSite* it)
- {
- if( m_pTopLevelSite && m_pTopLevelSite->m_pMutex )
- _TLSLock();
- m_bUsingList = FALSE;
- CHXBaseSite* pNotUsed = NULL;
- if( NULL==m_AlphaBlendNotifiers.Lookup( (void*)it) )
- {
- //Does not exist yet.
- it->AddRef();
- m_AlphaBlendNotifiers.SetAt( it, it );
- }
- m_bUsingList = FALSE;
- if( m_pTopLevelSite && m_pTopLevelSite->m_pMutex )
- _TLSUnlock();
- }
- void CHXBaseSite::_RemoveAllNotifiers()
- {
- _EmptyNotifierList();
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->_RemoveAllNotifiers();
- }
- }
- void CHXBaseSite::_RemoveAllYUVImageLists()
- {
- m_pVideoSurface->_RemoveYUVImageLists();
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->_RemoveAllYUVImageLists();
- }
- }
- // #if defined(_CHECK_PERFORMANCE)
- // LONG32 g_nNumTimes = 0;
- // double g_fTotalTime = 0;
- // double g_fAverageTime = 0;
- // #endif
- void CHXBaseSite::RecomputeClip()
- {
- // #if defined(_CHECK_PERFORMANCE)
- // double frequency, startTime;
- // static LARGE_INTEGER QueryPerformanceCounterResult = {0,0};
- // static LARGE_INTEGER QueryPerformanceFrequencyResult = {0,0};
- // if (this == m_pTopLevelSite)
- // {
- // QueryPerformanceFrequency(&QueryPerformanceFrequencyResult);
- // frequency = ((double)QueryPerformanceFrequencyResult.LowPart + 4294967296.0*QueryPerformanceFrequencyResult.HighPart);
- // QueryPerformanceCounter(&QueryPerformanceCounterResult);
- // startTime = ((double)QueryPerformanceCounterResult.LowPart + 4294967296.0*QueryPerformanceCounterResult.HighPart)/frequency;
- // }
- // #endif
- if( IsCompositionLocked() )
- {
- return;
- }
- m_bRegionIsValid = FALSE;
- //Need to clean up the notifier list here....
- if( this==m_pTopLevelSite )
- {
- _RemoveAllNotifiers();
- }
- //If we are a YUV site, add ourselves to the list.
- int nCID = GETBITMAPCOLOR(&(m_pVideoSurface->m_bmiLastBlt));
- if( IsYUV(nCID) )
- {
- if( !zm_YUVSiteList.Find(this) )
- {
- zm_YUVSiteList.AddTail(this);
- }
- }
- // this recomputes our clipping rect.
- if( ComputeSubRects() )
- {
- //We need to do this in Z-Order. So, create a temp map
- //and use the zorder as key and the pSite pointer as value.
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->RecomputeClip();
- }
- }
- // do we have video under transition?
- if( this==m_pTopLevelSite)
- {
- FindLinkedSites();
- }
- SetClipping();
- // #if defined(_CHECK_PERFORMANCE)
- // if (this == m_pTopLevelSite)
- // {
- // QueryPerformanceCounter(&QueryPerformanceCounterResult);
- // double endTime = ((double)QueryPerformanceCounterResult.LowPart + 4294967296.0*QueryPerformanceCounterResult.HighPart)/frequency;
- // if (endTime > startTime)
- // {
- // g_nNumTimes++;
- // g_fTotalTime += endTime - startTime;
- // g_fAverageTime = g_fTotalTime / (double) g_nNumTimes;
- // }
- // if( g_nNumTimes%50==0 )
- // {
- // FILE* pFP=fopen("c:\file.txt", "a+");
- // if( pFP )
- // {
- // fprintf( pFP, "ave: %f num: %ld tot: %fn",
- // g_fAverageTime, g_nNumTimes, g_fTotalTime);
- // fclose( pFP );
- // }
- // }
- // }
- // #endif
- }
- void CHXBaseSite::FindLinkedSites()
- {
- m_ListOfRealVideoSites.RemoveAll();
- m_bVideoUnderTransition = FALSE;
- FindVideoSites();
- if (m_bVideoUnderTransition && m_ListOfRealVideoSites.GetCount() > 1)
- {
- // find out which one (if any) has overlay.
- // note: we should make this work with more than one overlay in the future.
- CHXSimpleList::Iterator i = m_ListOfRealVideoSites.Begin();
- CHXBaseSite* pSite = NULL;
- CHXBaseSite* pLinkedSite = NULL;
- for(;i!=m_ListOfRealVideoSites.End(); ++i)
- {
- pSite = (CHXBaseSite*) *i;
- if (pSite->m_pVideoSurface->m_surfaceSize.cx != 0 && pSite->m_pVideoSurface->m_nBltMode == HX_OVERLAY_BLT)
- {
- break;
- }
- pSite = NULL;
- }
- #ifdef DEBUG_LINKING
- {
- char szbuff[255]; /* Flawfinder: ignore */
- sprintf(szbuff, "Under Transition Master Site = %pn", pSite); /* Flawfinder: ignore */
- OutputDebugString(szbuff);
- }
- #endif
- // yup it looks like one of the sites has overlay.
- if (pSite)
- {
- i = m_ListOfRealVideoSites.Begin();
- for(;i!=m_ListOfRealVideoSites.End(); ++i)
- {
- pLinkedSite = (CHXBaseSite*) *i;
- if (pLinkedSite != pSite &&
- pLinkedSite->m_topleft.x == pSite->m_topleft.x &&
- pLinkedSite->m_topleft.y == pSite->m_topleft.y &&
- pLinkedSite->m_size.cx == pSite->m_size.cx &&
- pLinkedSite->m_size.cy == pSite->m_size.cy
- )
- {
- // we have a site on top of us. And it is at least partially visible.
- pLinkedSite->m_pVideoSurface->LinkOverlay(pSite);
- pSite->m_pVideoSurface->AddLinkedSite(pLinkedSite);
- // of course we have to come up with some mechanisim to unlink the overlay.
- #ifdef DEBUG_LINKING
- {
- char szbuff[255]; /* Flawfinder: ignore */
- sprintf(szbuff, "Linking Site %p Surface %p to Site %p n", pLinkedSite, pLinkedSite->m_pVideoSurface, pSite); /* Flawfinder: ignore */
- OutputDebugString(szbuff);
- }
- #endif
- }
- else
- {
- #ifdef DEBUG_LINKING
- if (pLinkedSite != pSite)
- {
- char szbuff[255]; /* Flawfinder: ignore */
- sprintf(szbuff, "NO link (%d, %d, %d, %d) != (%d, %d, %d, %d)n", /* Flawfinder: ignore */
- pLinkedSite->m_topleft.x, pLinkedSite->m_topleft.y,
- pLinkedSite->m_size.cx, pLinkedSite->m_size.cy,
- pSite->m_topleft.x, pSite->m_topleft.y,
- pSite->m_size.cx, pSite->m_size.cy);
- OutputDebugString(szbuff);
- }
- #endif
- }
- }
- }
- }
- }
- void CHXBaseSite::SetClipping()
- {
- if (m_pParentSite && m_pWindow && m_pWindow->window)
- {
- static CHXMapPtrToPtr z_map;
- int i;
- if (!z_map.Lookup(this, (void*&)i))
- {
- i= z_map.GetCount();
- z_map.SetAt(this, (void*&)i);
- }
- #ifdef _DEBUG
- if (m_Region->numRects)
- {
- FILE* f = fopen("c:\blt.txt", "a+"); /* Flawfinder: ignore */
- fprintf(f, "index: %d this - %d hwnd %d VISIBLE: %s (%d, %d, %d, %d) NumBoxes: %d n", i, this,
- m_pWindow->window, m_bIsVisible ? "TRUE" : "FALSE",
- (INT32)m_topleft.x,
- (INT32)m_topleft.y,
- (INT32)m_size.cx,
- (INT32)m_size.cy, m_Region->numRects);
- fclose(f);
- }
- #endif
- // *** HMW - Fix a windowed renderer window (HWND) positioning bug.
- // The x and y positions was previously picked up from m_position, causing the child window to always be positioned at 0,0
- SafeMoveWindow((void*) m_pWindow->window,
- (int)m_topleft.x,
- (int)m_topleft.y,
- (int)m_size.cx ,
- (int)m_size.cy ,
- m_bIsVisible);
- SafeSetWindowRgn(m_pWindow->window, m_Region, TRUE);
- // XXXAH This is all buggered up. Have to fix
- }
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->SetClipping();
- }
- }
- void CHXBaseSite::FindVideoSites()
- {
- #ifdef DEBUG_LINKING
- {
- char szbuff[255]; /* Flawfinder: ignore */
- sprintf(szbuff, "FindVideoSites this = %ptRects: %dtCID=%dtblts= %sn", /* Flawfinder: ignore */
- this,
- m_Region->numRects,
- m_pVideoSurface->m_nSrcCID,
- !m_bSiteNeverBlts ? "TRUE":"FALSE");
- OutputDebugString(szbuff);
- }
- #endif
- if( IsYUV(GETBITMAPCOLOR(&m_pVideoSurface->m_bmiLastBlt)))
- {
- if (! m_Region->numRects && !m_AlphaBlendNotifiers.GetCount())
- {
- // m_pVideoSurface->RelinquishOverlay();
- }
- else
- {
- if ( !m_bSiteNeverBlts && !_BlendedBordersActive() && !_BordersActive())
- {
- m_pTopLevelSite->m_ListOfRealVideoSites.AddTail(this);
- if (m_fpTransitionEffect != DefaultTransition)
- {
- m_pTopLevelSite->m_bVideoUnderTransition = TRUE;
- }
- }
- }
- }
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->FindVideoSites();
- }
- }
- INT32 CHXBaseSite::GetTopMostSiteZOrder()
- {
- INT32 nZorder = 0;
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetTail();
- if( pSite )
- pSite->GetZOrder(nZorder);
- return nZorder;
- }
- void CHXBaseSite::SetParentWindow(HXxWindow* pWindow)
- {
- if (pWindow)
- {
- memcpy(&m_TopLevelWindow, pWindow, sizeof(HXxWindow)); /* Flawfinder: ignore */
- }
- else
- {
- memset(&m_TopLevelWindow, 0 , sizeof(HXxWindow));
- }
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->SetParentWindow(pWindow);
- }
- }
- void CHXBaseSite::SetRootSurface(CBaseRootSurface* pSurface)
- {
- HX_RELEASE(m_pRootSurface);
- m_pRootSurface = pSurface;
- if (m_pRootSurface)
- {
- m_pRootSurface->AddRef();
- // Enable/Disable optimized video
- IHXPreferences* pPreferences = NULL;
- IHXBuffer* pBuffer = NULL;
- if (HXR_OK == m_pContext->QueryInterface(IID_IHXPreferences,(void**)&pPreferences))
- {
- if (pPreferences->ReadPref("UseWinDraw", pBuffer) == HXR_OK)
- {
- BOOL bUseWindraw = ::atoi((char*) pBuffer->GetBuffer()) == 1;
- if (bUseWindraw)
- m_pRootSurface->_EnableHardwareAcceleration();
- else
- m_pRootSurface->_DisableHardwareAcceleration();
- HX_RELEASE(pBuffer);
- }
- HX_RELEASE(pPreferences);
- }
- }
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->SetRootSurface(pSurface);
- }
- }
- void CHXBaseSite::CheckColorSettings()
- {
- // NOTE 40 steps of granularity for color control parameters (based on
- // below float to int precision; proper rounding is not essential)
- if (m_pParentSite)
- {
- m_pParentSite->CheckColorSettings();
- return;
- }
- float fCurrentBrightness;
- float fCurrentContrast;
- float fCurrentSaturation;
- float fCurrentHue;
- zm_pColorAcc->GetColorAdjustments(&fCurrentBrightness, &fCurrentContrast, &fCurrentSaturation, &fCurrentHue);
- if( (int)(fCurrentBrightness * 20.f) != (int)(m_fBrightness * 20.f) ||
- (int)(fCurrentContrast * 20.f) != (int)(m_fContrast * 20.f) ||
- (int)(fCurrentSaturation * 20.f) != (int)(m_fSaturation * 20.f) ||
- (int)(fCurrentHue * 20.f) != (int)(m_fHue * 20.f) )
- {
- // Adjust colors according to video control settings
- zm_pColorAcc->SetColorAdjustments(m_fBrightness,
- m_fContrast, m_fSaturation, m_fHue);
- }
- float fCurrentSharpness;
- INT16 bInterpolate;
- zm_pColorAcc->GetSharpnessAdjustments(&fCurrentSharpness, &bInterpolate);
- if (fCurrentSharpness != m_fSharpness)
- {
- zm_pColorAcc->SetSharpnessAdjustments(m_fSharpness, FALSE);
- }
- }
- BOOL CHXBaseSite::SharpenImage(HXBitmapInfoHeader* pOptimizedFormat, UCHAR* pImageBits, REF(HXxRect) rSrcRect)
- {
- if (m_pParentSite)
- {
- return m_pParentSite->SharpenImage(pOptimizedFormat, pImageBits, rSrcRect);
- }
- BOOL bDidSharpen = FALSE;
- if( zm_pColorAcc &&
- (m_fSharpness+1.0)>0.1 &&
- IsYUVPlanar(GETBITMAPCOLOR(pOptimizedFormat)) )
- {
- INT32 nSrcWidth = rSrcRect.right - rSrcRect.left;
- INT32 nSrcHeight = rSrcRect.bottom - rSrcRect.top;
- bDidSharpen = TRUE;
- INT32 ulSrcPitch = GETBITMAPPITCH(pOptimizedFormat);
- INT32 ulYOffset = rSrcRect.top * ulSrcPitch + rSrcRect.left;
- UCHAR* ySrc = pImageBits + ulYOffset;
- //do edge enhancement if it is not already done once
- if(ySrc[0] != 1)
- {
- if(m_bModeSharpness)
- {
- //Deblocking filter is ON
- zm_pColorAcc->EnhanceUniform(ySrc,nSrcHeight,
- nSrcWidth,ulSrcPitch,m_fSharpness);
- }
- else
- {
- //Deblocking filter is OFF
- zm_pColorAcc->Enhance(ySrc,nSrcHeight,
- nSrcWidth,ulSrcPitch,m_fSharpness);
- }
- }
- else
- {
- //replicate pixel
- ySrc[0]=ySrc[1];
- }
- }
- return bDidSharpen;
- }
- void CHXBaseSite::SiteMoving(INT32 x, INT32 y)
- {
- #if 1
- m_bMoving = TRUE;
- m_pVideoSurface->UpdateDestRect(x,y);
- #else
- //GDI mode is *way* too expensive if we have alphablended ARGB
- //content ontop of it. It just kills the whole system. So, we
- //will stay in overlay mode in those cases.
- if( !m_pVideoSurface->m_bYUVBlending )
- {
- if( !m_pVideoSurface->ForceGDIMode(TRUE))
- m_pVideoSurface->UpdateDestRect(x,y);
- }
- else
- {
- m_pVideoSurface->UpdateDestRect(x,y);
- }
- #endif
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pChildSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pChildSite->SiteMoving(x,y);
- }
- if( this == m_pTopLevelSite )
- {
- FillColorKey();
- ScheduleCallback( REDRAW_ALL, 0 );
- }
- }
- void
- CHXBaseSite::ResetOrigin()
- {
- m_topleft.x =0;
- m_topleft.y =0;
- GetAbsoluteCords(m_topleft);
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pChildSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pChildSite->ResetOrigin();
- }
- }
- void
- CHXBaseSite::GetAbsoluteCords(REF(HXxPoint) point)
- {
- point.x += m_position.x;
- point.y += m_position.y;
- if (m_pParentSite)
- {
- m_pParentSite->GetAbsoluteCords(point);
- }
- return;
- }
- void
- CHXBaseSite::AboutToBlt()
- {
- if (m_pTopLevelSite != this)
- {
- m_pTopLevelSite->AboutToBlt();
- return;
- }
- if (m_bAboutToBlt)
- {
- return;
- }
- m_bAboutToBlt = TRUE;
- if (m_bRecomputeClipScheduled)
- {
- if (m_CallbackHandle)
- {
- m_pScheduler->Remove(m_CallbackHandle);
- m_CallbackHandle = 0;
- }
- Func();
- }
- m_bAboutToBlt = FALSE;
- }
- void
- CHXBaseSite::FillColorKey()
- {
- m_pVideoSurface->FillColorKey();
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->FillColorKey();
- }
- }
- BOOL
- CHXBaseSite::SafeMoveWindow(void* hWnd, INT32 X, INT32 Y, INT32 nWidth, INT32 nHeight, BOOL bRepaint)
- {
- if (_AtSystemTime())
- {
- m_pTopLevelSite->ExecutePendingTasks();
- return _MoveWindow(hWnd, X, Y, nWidth, nHeight, bRepaint);
- }
- PendingTask* pPendingTask = new PendingTask(ONMOVEWINDOW, this, (void*) hWnd, (void*) X, (void*) Y, (void*) nWidth, (void*) nHeight, (void*) bRepaint);
- m_pTopLevelSite->m_PendingTaskList.AddTail((void*) pPendingTask);
- m_pTopLevelSite->ScheduleCallback(MOUSE, 0);
- return TRUE;
- }
- BOOL
- CHXBaseSite::SafeUpdateWindow(void* hWnd)
- {
- if (_AtSystemTime())
- {
- m_pTopLevelSite->ExecutePendingTasks();
- return _UpdateWindow(hWnd);
- }
- PendingTask* pPendingTask = new PendingTask(ONUPDATEWINDOW, this, (void*) hWnd);
- m_pTopLevelSite->m_PendingTaskList.AddTail((void*) pPendingTask);
- m_pTopLevelSite->ScheduleCallback(MOUSE, 0);
- return TRUE;
- }
- BOOL CHXBaseSite::SafeShowWindow(void* hWnd, INT32 nCmdShow)
- {
- if (_AtSystemTime())
- {
- m_pTopLevelSite->ExecutePendingTasks();
- return _ShowWindow(hWnd, nCmdShow);
- }
- PendingTask* pPendingTask = new PendingTask(ONSHOWWINDOW, this, (void*) hWnd, (void*) nCmdShow);
- m_pTopLevelSite->m_PendingTaskList.AddTail((void*) pPendingTask);
- m_pTopLevelSite->ScheduleCallback(MOUSE, 0);
- return TRUE;
- }
- BOOL CHXBaseSite::SafeSetWindowPos(void* hWnd, void* hWndInsertAfter, INT32 X, INT32 Y, INT32 cx, INT32 cy, UINT uFlags)
- {
- if (_AtSystemTime())
- {
- m_pTopLevelSite->ExecutePendingTasks();
- BOOL ret = _SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
- return ret;
- }
- PendingTask* pPendingTask = new PendingTask(ONSETWINDOWPOS, this, (void*) hWnd, (void*) hWndInsertAfter, (void*) X, (void*) Y, (void*) cx, (void*) cy, (void*) uFlags);
- m_pTopLevelSite->m_PendingTaskList.AddTail((void*) pPendingTask);
- m_pTopLevelSite->ScheduleCallback(MOUSE, 0);
- return TRUE;
- }
- INT32 CHXBaseSite::SafeSetWindowRgn(void* hWnd, HXREGION* hRgn, BOOL bRedraw)
- {
- if (_AtSystemTime())
- {
- m_pTopLevelSite->ExecutePendingTasks();
- return _SetWindowRgn(hWnd, hRgn, bRedraw);
- }
- // create a temp region
- HXREGION* hTemp = NULL;
- hTemp = HXCreateRectRegion(0,0,0,0);
- HXUnionRegion(hTemp, hRgn, hTemp);
- PendingTask* pPendingTask = new PendingTask(ONSETWINDOWREGION, this, (void*) hWnd, (void*) hTemp, (void*) bRedraw);
- m_pTopLevelSite->m_PendingTaskList.AddTail((void*) pPendingTask);
- m_pTopLevelSite->ScheduleCallback(MOUSE, 0);
- return 1;
- }
- void CHXBaseSite::SafeSetXSliderRange(INT32 range)
- {
- if (_AtSystemTime())
- {
- m_pTopLevelSite->ExecutePendingTasks();
- SetXSliderRange(range);
- return;
- }
- PendingTask* pPendingTask = new PendingTask(ONSETXSLIDER, this, (void*) range);
- m_pTopLevelSite->m_PendingTaskList.AddTail((void*) pPendingTask);
- m_pTopLevelSite->ScheduleCallback(MOUSE, 0);
- }
- void CHXBaseSite::SafeSetYSliderRange(INT32 range)
- {
- if (_AtSystemTime())
- {
- m_pTopLevelSite->ExecutePendingTasks();
- SetYSliderRange(range);
- return;
- }
- PendingTask* pPendingTask = new PendingTask(ONSETYSLIDER, this, (void*) range);
- m_pTopLevelSite->m_PendingTaskList.AddTail((void*) pPendingTask);
- m_pTopLevelSite->ScheduleCallback(MOUSE, 0);
- }
- void CHXBaseSite::SafeSetFocus(HXxWindow* pWindow)
- {
- if (_AtSystemTime())
- {
- m_pTopLevelSite->ExecutePendingTasks();
- _SetFocus(pWindow->window);
- return;
- }
- PendingTask* pPendingTask = new PendingTask(ONSETFOCUS, this, (void*) pWindow);
- m_pTopLevelSite->m_PendingTaskList.AddTail((void*) pPendingTask);
- m_pTopLevelSite->ScheduleCallback(MOUSE, 0);
- }
- void
- CHXBaseSite::ExecutePendingTasks()
- {
- if (_AtSystemTime())
- {
- while(m_PendingTaskList.GetCount())
- {
- PendingTask* pPendingTask = (PendingTask*) m_PendingTaskList.RemoveHead();
- switch(pPendingTask->m_TaskType)
- {
- case ONMOVEWINDOW:
- _MoveWindow(pPendingTask->m_ulArg1, (int) pPendingTask->m_ulArg2, (int) pPendingTask->m_ulArg3, (int) pPendingTask->m_ulArg4, (int) pPendingTask->m_ulArg5, (BOOL) (int) pPendingTask->m_ulArg6);
- break;
- case ONUPDATEWINDOW:
- _UpdateWindow(pPendingTask->m_ulArg1);
- break;
- case ONSHOWWINDOW:
- _ShowWindow(pPendingTask->m_ulArg1, (int) pPendingTask->m_ulArg2);
- break;
- case ONSETWINDOWPOS:
- _SetWindowPos(pPendingTask->m_ulArg1, pPendingTask->m_ulArg2, (int) pPendingTask->m_ulArg3, (int) pPendingTask->m_ulArg4, (int) pPendingTask->m_ulArg5, (int) pPendingTask->m_ulArg6, (UINT) pPendingTask->m_ulArg7);
- break;
- case ONSETWINDOWREGION:
- _SetWindowRgn( pPendingTask->m_ulArg1, (HXREGION*)pPendingTask->m_ulArg2, (BOOL) pPendingTask->m_ulArg3);
- HXDestroyRegion((HXREGION*)pPendingTask->m_ulArg2);
- break;
- case ONSETXSLIDER:
- pPendingTask->m_pThis->SetXSliderRange((int)pPendingTask->m_ulArg1);
- break;
- case ONSETYSLIDER:
- pPendingTask->m_pThis->SetYSliderRange((int)pPendingTask->m_ulArg1);
- break;
- case ONSETFOCUS:
- pPendingTask->m_pThis->_SetFocus( pPendingTask->m_ulArg1);
- break;
- case ONSETSIZE:
- HXxSize size;
- size.cx = (long)pPendingTask->m_ulArg1;
- size.cy = (long)pPendingTask->m_ulArg2;
- pPendingTask->m_pThis->_SafeSetSize(size);
- break;
- case ONSETPOSITION:
- HXxPoint position;
- position.x = (long)pPendingTask->m_ulArg1;
- position.y = (long)pPendingTask->m_ulArg2;
- pPendingTask->m_pThis->_SafeSetPosition(position);
- break;
- default:
- HX_ASSERT(FALSE);
- break;
- }
- HX_DELETE(pPendingTask);
- }
- }
- }
- void
- CHXBaseSite::RemovePendingTasks(CHXBaseSite* pThis)
- {
- LISTPOSITION pPos;
- pPos = m_PendingTaskList.GetHeadPosition();
- while(pPos)
- {
- PendingTask* pPendingTask = (PendingTask*) m_PendingTaskList.GetAt(pPos);
- if (pPendingTask->m_pThis == pThis)
- {
- pPos = m_PendingTaskList.RemoveAt(pPos);
- HX_DELETE(pPendingTask);
- }
- else
- {
- m_PendingTaskList.GetNext(pPos);
- }
- }
- }
- void CHXBaseSite::ResetUpdateOverlay()
- {
- if (m_pVideoSurface)
- {
- m_pVideoSurface->ResetUpdateOverlay();
- }
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->ResetUpdateOverlay();
- }
- }
- HXREGION* CHXBaseSite::Transition(INT32 left, INT32 top, INT32 right, INT32 bottom, tranLines* lines)
- {
- INT32 completeness = m_nTransitionState;
- if (lines)
- lines->Destroy();
- // if this is a default transition we don't ever want to invert it!
- if (m_fpTransitionEffect == DefaultTransition ||
- m_fpTransitionEffect == SlideFromLeft ||
- m_fpTransitionEffect == SlideFromBottom ||
- m_fpTransitionEffect == SlideFromRight ||
- m_fpTransitionEffect == SlideFromTop ||
- m_fpTransitionEffect == Crossfade ||
- m_fpTransitionEffect == FadeFromColor ||
- m_fpTransitionEffect == FadeToColor
- )
- {
- return m_fpTransitionEffect(left, top, right, bottom, completeness, NULL);
- }
- tranLines* tmpLines = (completeness > 0 && completeness < 1000) ? lines : NULL;
- HXREGION* retRGN = HXCreateRegion();
- double vSize = double(bottom - top) / double(m_nTransitionVertRepeat);
- double hSize = double(right - left) / double(m_nTransitionHorzRepeat);
- if (m_bTransitionReversed)
- completeness = 1000 - m_nTransitionState;
- for (int h = 0; h < m_nTransitionHorzRepeat; ++h)
- {
- for (int v = 0; v < m_nTransitionVertRepeat; ++v)
- {
- INT32 l = left + int(hSize * h);
- INT32 t = top + int(vSize * v);
- HXREGION* tmpRgn = m_fpTransitionEffect(l, t, int(l + hSize), int(t + vSize), completeness, tmpLines);
- HXCombineRgn( retRGN, retRGN, tmpRgn, HX_RGN_OR);
- HXDestroyRegion(tmpRgn);
- }
- }
- if (tmpLines)
- tmpLines->Clip(left, top, right - 1, bottom - 1);
- if (!(m_bTransitionTranIn ^ m_bTransitionReversed))
- retRGN = InvertRGN(retRGN, left, top, right, bottom);
- //Intersect with our rect.
- HXREGION* pMe = HXCreateRectRegion( m_topleft.x,
- m_topleft.y,
- m_size.cx,
- m_size.cy
- );
- HXIntersectRegion( retRGN, pMe, retRGN );
- HXDestroyRegion( pMe );
- return retRGN;
- }
- //Incoming coords are OS Winow relative....
- void CHXBaseSite::_RecursiveDamageRect( HXxRect* dirtyRect, BOOL bForce )
- {
- HXxRect rect = {0, 0, 0, 0};
- HXREGION* pReg = HXCreateRectRegion( dirtyRect->left,
- dirtyRect->top,
- dirtyRect->right-dirtyRect->left,
- dirtyRect->bottom-dirtyRect->top
- );
- //Find out what part intersects us.
- HXREGION* pTemp = HXCreateRegion();
- HXxPoint* pPosition = GetOrigin();
- if( m_Region && !bForce )
- {
- HXIntersectRegion( m_Region, pReg, pTemp );
- }
- else
- {
- HXZeroOutRegion( pTemp );
- HXUnionRegion( pTemp, pReg, pTemp );
- }
- if( !HXEmptyRegion(pTemp) )
- {
- HXUnionRegion(m_pDirtyRegion, pTemp, m_pDirtyRegion );
- //We must now verify our dirty region does not fall outside of our
- //real boundries. If the site is animated it can move in such a
- //way that we will get negative offsets once we turn the region to
- //site relative coordinates in the HX_SURFACE_UPDATE2 message.
- HXDestroyRegion( pTemp );
- pTemp = Transition( pPosition->x, pPosition->y,
- pPosition->x + m_size.cx,
- pPosition->y + m_size.cy
- );
- HXIntersectRegion( pTemp, m_pDirtyRegion, m_pDirtyRegion );
- }
- HXDestroyRegion( pTemp );
- HXDestroyRegion( pReg );
- CHXSimpleList::Iterator it = m_ChildrenInZOrder.Begin();
- while( it != m_ChildrenInZOrder.End() )
- {
- CHXBaseSite* pSite = (CHXBaseSite*)*it;
- if( pSite )
- pSite->_RecursiveDamageRect(dirtyRect, bForce);
- ++it;
- }
- }
- //Incoming coords are OS Winow relative....
- void CHXBaseSite::ManageExposeEvents( HXxRect* dirtyRect )
- {
- //We may not be the toplevel site if there is a windowed renderer
- //being used.
- _RecursiveDamageRect(dirtyRect);
- ResetUpdateOverlay();
- FillColorKey();
- m_pTopLevelSite->_ForceRedrawAll();
- }
- void CHXBaseSite::InternalForceRedraw()
- {
- m_bSiteRefresh = TRUE;
- ForceRedraw();
- m_bSiteRefresh = FALSE;
- }
- ////////////////////////////////////////////////
- //
- // basesite callback
- //
- ////////////////////////////////////////////////
- BaseSiteCallback::BaseSiteCallback(CHXBaseSite* pSite) :
- m_lRefCount (0)
- ,m_pSite(pSite)
- {
- }
- BaseSiteCallback::~BaseSiteCallback()
- {
- }
- STDMETHODIMP BaseSiteCallback::QueryInterface(REFIID riid, void** ppvObj)
- {
- if (IsEqualIID(riid, IID_IHXCallback))
- {
- AddRef();
- *ppvObj = (IHXCallback*)this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IUnknown))
- {
- AddRef();
- *ppvObj = this;
- return HXR_OK;
- }
- *ppvObj = NULL;
- return HXR_NOINTERFACE;
- }
- STDMETHODIMP_(ULONG32) BaseSiteCallback::AddRef()
- {
- return m_pSite->AddRef();
- }
- STDMETHODIMP_(ULONG32) BaseSiteCallback::Release()
- {
- return m_pSite->Release();
- }
- STDMETHODIMP BaseSiteCallback::Func(void)
- {
- if(m_pSite)
- {
- m_pSite->Func();
- }
- return HXR_OK;
- }
- ScrollSiteCallback::ScrollSiteCallback(CHXBaseSite* pSite) :
- m_lRefCount (0)
- ,m_pSite(pSite)
- {
- }
- ScrollSiteCallback::~ScrollSiteCallback()
- {
- }
- STDMETHODIMP ScrollSiteCallback::QueryInterface(REFIID riid, void** ppvObj)
- {
- if (IsEqualIID(riid, IID_IHXCallback))
- {
- AddRef();
- *ppvObj = (IHXCallback*)this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IUnknown))
- {
- AddRef();
- *ppvObj = this;
- return HXR_OK;
- }
- *ppvObj = NULL;
- return HXR_NOINTERFACE;
- }
- STDMETHODIMP_(ULONG32) ScrollSiteCallback::AddRef()
- {
- return m_pSite->AddRef();
- }
- STDMETHODIMP_(ULONG32) ScrollSiteCallback::Release()
- {
- return m_pSite->Release();
- }
- STDMETHODIMP ScrollSiteCallback::Func(void)
- {
- if(m_pSite)
- {
- m_pSite->FuncSizeSliders();
- }
- return HXR_OK;
- }
- STDMETHODIMP CHXBaseSite::LockComposition()
- {
- if(m_pParentSite)
- {
- return m_pParentSite->LockComposition();
- }
- if( !m_bCompositionMode )
- return HXR_FAIL;
- m_bCompositionLocked = TRUE;
- return HXR_OK;
- }
- STDMETHODIMP CHXBaseSite::SetCompositionMode(BOOL OnOrOff )
- {
- if(m_pParentSite)
- {
- return m_pParentSite->SetCompositionMode(OnOrOff);
- }
- m_bCompositionMode = OnOrOff;
- return HXR_OK;
- }
- STDMETHODIMP CHXBaseSite::UnlockComposition()
- {
- HX_RESULT ret = HXR_OK;
- _TLSLock();
- if( m_pParentSite)
- {
- ret = m_pParentSite->UnlockComposition();
- _TLSUnlock();
- return ret;
- }
- if( !m_bCompositionMode )
- {
- _TLSUnlock();
- return HXR_FAIL;
- }
- m_bCompositionLocked = FALSE;
- //Do a recompute clip and redraw all.
- HX_ASSERT( m_pParentSite==NULL);
- HX_ASSERT( this == m_pTopLevelSite );
- m_bDisableForceRedraw = TRUE;
- RecomputeClip();
- m_bDisableForceRedraw = FALSE;
- _ForceRedrawAll();
- m_bCalledComputeClipFromTransition = FALSE;
- FillColorKey();
- _TLSUnlock();
- return HXR_OK;
- }
- STDMETHODIMP CHXBaseSite::BltComposition()
- {
- HX_RESULT ret = HXR_OK;
- _TLSLock();
- if( m_pParentSite)
- {
- ret = m_pParentSite->BltComposition();
- _TLSUnlock();
- return ret;
- }
- //Tell the root surface to blt itself.
- #if defined(_TEST_COMPOSITION)
- {
- char szBuff[256]; /* Flawfinder: ignore */
- sprintf( szBuff,"tick count: %lun", HX_GET_TICKCOUNT()); /* Flawfinder: ignore */
- _DumpString(szBuff);
- }
- #endif
- if( m_pRootSurface )
- m_pRootSurface->BltComposition();
- _TLSUnlock();
- return HXR_OK;
- }
- STDMETHODIMP_(BOOL) CHXBaseSite::IsCompositionLocked()
- {
- if( m_pParentSite)
- {
- return m_pParentSite->IsCompositionLocked();
- }
- return m_bCompositionLocked && m_bCompositionMode;
- }
- STDMETHODIMP_(BOOL) CHXBaseSite::IsCompositionMode()
- {
- if( m_pParentSite)
- {
- return m_pParentSite->IsCompositionMode();
- }
- return m_bCompositionMode;
- }
- void CHXBaseSite::_TLSLock()
- {
- if( m_pTopLevelSite)
- {
- if( this != m_pTopLevelSite )
- m_pTopLevelSite->_TLSLock();
- else
- {
- m_pMutex->Lock();
- InterlockedIncrement(&m_nTLSMutexLockCount);
- m_ulTLSMutexOwningThread = m_pDummyThread->GetCurrentThreadID();
- }
- }
- }
- void CHXBaseSite::_TLSUnlock()
- {
- if( m_pTopLevelSite)
- {
- if( this != m_pTopLevelSite )
- m_pTopLevelSite->_TLSUnlock();
- else
- {
- HX_ASSERT(m_nTLSMutexLockCount>0);
- m_pMutex->Unlock();
- InterlockedDecrement(&m_nTLSMutexLockCount);
- }
- }
- }
- BOOL CHXBaseSite::_TLSIsLocked()
- {
- if( m_pTopLevelSite)
- {
- if( this != m_pTopLevelSite )
- return m_pTopLevelSite->_TLSIsLocked();
- else
- {
- HX_ASSERT( m_nTLSMutexLockCount >=0 );
- return (m_ulTLSMutexOwningThread!=m_pDummyThread->GetCurrentThreadID() &&
- m_nTLSMutexLockCount>0);
- }
- }
- HX_ASSERT("oops"==NULL);
- return FALSE;
- }
- HX_RESULT CHXBaseSite::SendSubRectMessages(BOOL bRet)
- {
- if( m_pVideoSurface && IsYUV(GETBITMAPCOLOR( &m_pVideoSurface->m_bmiLastBlt)) )
- {
- m_bUserWantsSubRects = FALSE;
- return HXR_FAIL;
- }
- m_bUserWantsSubRects = bRet;
- m_bSiteScalingInfo = TRUE;
- return HXR_OK;
- }
- //These are in SITE relative coords.
- HX_RESULT CHXBaseSite::SubRectDamageRegion( HXxBoxRegion* pRegion )
- {
- HXxRect rectTmp;
- if( !pRegion )
- return HXR_OK;
- HX_ASSERT( pRegion->rects );
- //Add each rect to our damage region.
- for( int i=0 ; i<pRegion->numRects ; i++ )
- {
- rectTmp.left = pRegion->rects[i].x1;
- rectTmp.top = pRegion->rects[i].y1;
- rectTmp.right = pRegion->rects[i].x2;
- rectTmp.bottom = pRegion->rects[i].y2;
- DamageRect( rectTmp );
- }
- return HXR_OK;
- }
- ///////////////////////
- // DEBUG METHODS
- ///////////////////////
- void CHXBaseSite::DisplaySiteData(const char *pszLeadIn)
- {
- #ifdef _DEBUG
- IHXBuffer* pBuf= NULL;
- char szBuff[256]; /* Flawfinder: ignore */
- if( m_pValues )
- {
- m_pValues->GetPropertyCString( "channel", pBuf );
- if( pBuf )
- {
- sprintf( szBuff, "%s -------------Site %p (%s)--------------n", pszLeadIn, this, (const char*)(pBuf->GetBuffer())); /* Flawfinder: ignore */
- _DumpString(szBuff);
- HX_RELEASE(pBuf);
- }
- else
- {
- sprintf( szBuff, "%s -------------Site %p --------------n", pszLeadIn, this); /* Flawfinder: ignore */
- _DumpString(szBuff);
- }
- }
- else
- {
- sprintf( szBuff, "%s -------------Site %p --------------n", pszLeadIn, this); /* Flawfinder: ignore */
- _DumpString(szBuff);
- }
- INT32 nCID = GETBITMAPCOLOR( &(m_pVideoSurface->m_bmiLastBlt) );
- sprintf( szBuff, "%s Size (%d, %d) zorder: %d visible: %d BltCID:%d SurfaceCID:%d AlphaChain: %dn", /* Flawfinder: ignore */
- pszLeadIn, m_size.cx, m_size.cy, m_lZOrder, IsSiteVisible(),
- nCID, m_pVideoSurface->m_nSurfaceCID, _TakesPartInAlphaChain() );
- _DumpString(szBuff);
- sprintf( szBuff, "%s Bounding Rect (parent rel): (%d, %d) - (%d, %d)n", /* Flawfinder: ignore */
- pszLeadIn, m_position.x, m_position.y,
- m_position.x + m_size.cx, m_position.y+m_size.cy );
- _DumpString(szBuff);
- sprintf( szBuff, "%s Bounding Rect (absolulte ): (%d, %d) - (%d, %d)n", /* Flawfinder: ignore */
- pszLeadIn, m_topleft.x, m_topleft.y,
- m_topleft.x+m_size.cx, m_topleft.y+m_size.cy);
- _DumpString(szBuff);
- sprintf( szBuff, "%s Window: %p m_pUser: %p EventSensitivity: ", /* Flawfinder: ignore */
- pszLeadIn,
- m_pWindow?m_pWindow->window:0, m_pUser
- );
- _DumpString(szBuff);
- if( m_nEventSensitivity==SENSITIVITY_TRANSPARENT)
- sprintf(szBuff, "TRANSPARENTn"); /* Flawfinder: ignore */
- else if( m_nEventSensitivity==SENSITIVITY_OPAQUE)
- sprintf(szBuff, "OPAQUEn"); /* Flawfinder: ignore */
- else if( m_nEventSensitivity==SENSITIVITY_NOT_SET)
- sprintf(szBuff, "NOT_SETn"); /* Flawfinder: ignore */
- else
- sprintf(szBuff, "%dn", m_nEventSensitivity); /* Flawfinder: ignore */
- _DumpString(szBuff);
- sprintf( szBuff, "%s Alpha(blend:%d noti: %d) m_bSiteNeverBlts: %d YUVAImageList: %d ImageBlocks: %dn", /* Flawfinder: ignore */
- pszLeadIn,
- m_AlphaBlendSites.GetCount(),
- m_AlphaBlendNotifiers.GetCount(),
- m_bSiteNeverBlts,
- m_pVideoSurface->m_YUVAImageList.GetCount(),
- m_pVideoSurface->m_imageBlocks.GetCount()
- );
- _DumpString(szBuff);
- CHXMapPtrToPtr::Iterator iter = m_AlphaBlendSites.Begin();
- for ( ; iter != m_AlphaBlendSites.End(); ++iter)
- {
- HXREGION* pTmp = (HXREGION*)*iter;
- CHXBaseSite* pSite = (CHXBaseSite*) iter.get_key();
- sprintf( szBuff, "%s %p num rects: %dn", /* Flawfinder: ignore */
- pszLeadIn,
- pSite,
- pTmp->numRects
- );
- _DumpString(szBuff);
- #if defined(_DUMP_REGION_RECTS) || 1
- for( int i=0 ; i<pTmp->numRects ; i++ )
- {
- sprintf( szBuff, "%s %d (%d, %d)-(%d, %d)n", pszLeadIn, i, /* Flawfinder: ignore */
- pTmp->rects[i].x1,
- pTmp->rects[i].y1,
- pTmp->rects[i].x2,
- pTmp->rects[i].y2
- );
- _DumpString( szBuff );
- }
- #endif
- }
- if( m_fpTransitionEffect != DefaultTransition )
- {
- sprintf( szBuff, "%s Num Sub Rects: Region:%d RegWC: %d RegForMouse: %d m_fpTransitionEffect: %p(%d)n", /* Flawfinder: ignore */
- pszLeadIn,
- !m_Region?0:m_Region->numRects,
- !m_RegionWithoutChildren?0:m_RegionWithoutChildren->numRects,
- !m_RegionForMouse?0:m_RegionForMouse->numRects,
- m_fpTransitionEffect,
- m_nTransitionState
- );
- }
- else
- {
- sprintf( szBuff, "%s Num Sub Rects: Region:%d RegWC: %d RegForMouse: %d m_fpTransitionEffect: DEFAULTn", /* Flawfinder: ignore */
- pszLeadIn,
- !m_Region?0:m_Region->numRects,
- !m_RegionWithoutChildren?0:m_RegionWithoutChildren->numRects,
- !m_RegionForMouse?0:m_RegionForMouse->numRects
- );
- }
- _DumpString(szBuff);
- #if defined(_DUMP_REGION_RECTS) || 1
- if( m_Region )
- {
- for( int i=0 ; i<m_Region->numRects ; i++ )
- {
- sprintf( szBuff, "%s %d (%d, %d)-(%d, %d)n", pszLeadIn, i, /* Flawfinder: ignore */
- m_Region->rects[i].x1,
- m_Region->rects[i].y1,
- m_Region->rects[i].x2,
- m_Region->rects[i].y2
- );
- _DumpString( szBuff );
- }
- }
- #endif
- #endif /* _DEBUG */
- }
- void CHXBaseSite::DisplayAllSiteData()
- {
- #ifdef _DEBUG
- CHXBaseSite* pTopSite = GetTopLevelSite();
- char szBuff[256]; /* Flawfinder: ignore */
- sprintf( szBuff, "************************************************n" ); /* Flawfinder: ignore */
- _DumpString(szBuff);
- sprintf( szBuff, "TOPLEVEL: Composition Mode: %s Composition Locked: %s n", /* Flawfinder: ignore */
- pTopSite->IsCompositionMode()?"TRUE":"FALSE",
- pTopSite->IsCompositionLocked()?"TRUE":"FALSE"
- );
- _DumpString(szBuff);
- sprintf( szBuff, "************************************************n" ); /* Flawfinder: ignore */
- _DumpString(szBuff);
- pTopSite->DisplayChildSiteData("");
- sprintf( szBuff, "************************************************n" ); /* Flawfinder: ignore */
- _DumpString(szBuff);
- sprintf( szBuff, "************************************************n" ); /* Flawfinder: ignore */
- _DumpString(szBuff);
- sprintf( szBuff, "List of YUV Sitesn" ); /* Flawfinder: ignore */
- _DumpString(szBuff);
- CHXSimpleList::Iterator i = zm_YUVSiteList.Begin();
- while( i != zm_YUVSiteList.End() )
- {
- sprintf( szBuff, "%pn", *i ); /* Flawfinder: ignore */
- _DumpString(szBuff);
- ++i;
- }
- #endif /* _DEBUG */
- }
- void CHXBaseSite::DisplayChildSiteData(const char *pszLeadIn)
- {
- #ifdef _DEBUG
- DisplaySiteData(pszLeadIn);
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- int nn=strlen(pszLeadIn)+10;
- char *pszTmp= new char[nn];
- memset(pszTmp, ' ', nn );
- pszTmp[nn-1]=' ';
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->DisplayChildSiteData(pszTmp);
- }
- delete [] pszTmp;
- #endif /* _DEBUG */
- }
- //Verify that we don't add any overlapping alphablend regions...
- void CHXBaseSite::VerifyNoDups( CHXMapPtrToPtr& map, HXREGION* reg )
- {
- #ifdef _DEBUG
- //Loop through and see if reg is already in the map.
- CHXMapPtrToPtr::Iterator iter = map.Begin();
- for ( ; iter != map.End(); ++iter)
- {
- HXREGION* pSiteReg = (HXREGION*)*iter;
- HXREGION* pTmp = HXCreateRegion();
- HXIntersectRegion( pSiteReg, reg, pTmp );
- if( !HXEmptyRegion(pTmp) )
- {
- DisplayAllSiteData();
- HX_ASSERT( "Adding a duplicate region!" );
- }
- HXDestroyRegion(pTmp);
- }
- #endif /* _DEBUG */
- }
- ///////////////////////
- // DEBUG METHODS END END END
- ///////////////////////