📄 basesite.cpp
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: basesite.cpp,v 1.20.4.2 2004/07/09 01:59:28 hubbe Exp $ * * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. * * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks. You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL. Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. * * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. * * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. * * Technology Compatibility Kit Test Suite(s) Location: * http://www.helixcommunity.org/content/tck * * Contributor(s): * * ***** END LICENSE BLOCK ***** */#include <stdlib.h> //for atof#include "hxcom.h"#include "hxtypes.h"#include "hxwintyp.h"#include "ihxpckts.h"#include "hxwin.h"#include "hxengin.h"#include "hxsite2.h"#include "hxevent.h"#include "hxcomm.h"#include "hxassert.h"#include "hxthread.h"#include "hxvsurf.h"#include "basesite.h"#include "basesurf.h"#include "baseroot.h"#ifdef _WINDOWS#include "winroot.h" //must be included before colormap.h#endif#include "colormap.h"#if defined(_UNIX) && !defined(_MAC_UNIX)#include "X11/Xlib.h"#include "X11/keysym.h"#include "unixsite.h"#include "hxiids.h"#include "hxcmenu.h"#endif#include "sitetext.h"//#include "hxwinver.h"#include "ihxpckts.h"#include "hxprefs.h"#include "hxtick.h"#include "hxcore.h"#include "hxupgrd.h"#include "addupcol.h"#include "mmx_util.h"#ifdef _WINDOWS#include "winsite.h"#endif#if defined(_MACINTOSH) || defined(_MAC_UNIX)//#include "../dcondev/dcon.h"#include "platform/mac/macsite.h"#endif#if defined(_UNIX) && !defined(_MAC_UNIX)#include "unixsite.h"#endif#include "hxheap.h"#include "colormap.h"#include "drawline.h"#include "hxvimlog.h"#include "sitefact.h"#if defined(HELIX_FEATURE_PREFERENCES)#include "hxprefs.h"#include "hxprefutil.h"#endif /* HELIX_FEATURE_PREFERENCES */#ifdef _DEBUG#undef HX_THIS_FILEstatic const char HX_THIS_FILE[] = __FILE__;#endif//XXXgfw just to clean up the code. We still *REALLY* need to clean//this up.#ifdef _WIN32#define GETBITMAPCOLOR(x) GetBitmapColor( (LPBITMAPINFO)(x) )#else#define GETBITMAPCOLOR(x) GetBitmapColor( (HXBitmapInfo*)(x))#endif#ifdef _WIN32#define GETBITMAPPITCH(x) GetBitmapPitch( (LPBITMAPINFO)(x) )#else#define GETBITMAPPITCH(x) GetBitmapPitch( (HXBitmapInfo*)(x))#endif/* * Full Screen Preferences Information */#define MODE_SEPERATOR "|"#define MODE_DESRIPTION_SEPS "xX"#define REGKEY_TESTED "Tested"#define REGKEY_BLT_TIME "BltTime"#define REGKEY_PASS "Passed"#define DIRECT_DRAW_DLL "ddraw.dll"#define REGKEY_FULLSCREEN_DATA "FullScreenData"#define REGKEY_FULLSCREEN_AVAILIABLE_MODES "AvailiableModes"#define REGKEY_FULLSCREEN_TEST_MODES "TestModes"#define REGKEY_FULLSCREEN_PREFERED_MODE "PreferedMode"#define REGKEY_NEW_FULLSCREEN_CODE "NewFullScreen"#define REGKEY_FULLSCREEN_NEW_STRING_FORMAT "NewStringFormat"#define REGKEY_DO_NOT_SETUP_DD "DoNotSetupDD"#define TEST_THRESHOLD 30#define REGKEY_FULLSCREEN_POSTAGE_STAMP "PostageStamp"#define TEST_LENGTH 6000#define NUM_OF_TEST_ITTERATIONS 2000#define MOVING_TIMEOUT 200 // MillisecondsBOOL CHXBaseSite::zm_bInFullScreenTest = FALSE;extern tranType z_TransitionTable[];extern INT32 z_nNumberTransitionTypes;//Out global list of YUV sites.CHXSimpleList CHXBaseSite::zm_YUVSiteList;//#define DEBUG_LINKING/************************************************************************ * Method: * Constructor */CHXBaseSite::CHXBaseSite(IUnknown* pContext, IUnknown* pUnkOuter, INT32 lZorder) : m_lRefCount(0) , zm_pColorAcc(NULL) , m_bIsChildWindow(FALSE) , m_pValues(0) , m_pUser(0) , m_pParentSite(0) , m_pVideoSurface(0) , m_pCCF(0) , m_pWatcher(0) , m_pContext(pContext) , m_pUnkOuter(pUnkOuter) , m_lZOrder(lZorder) , m_bIsVisible(TRUE) , m_bInDestructor(FALSE) , m_pRootSurface(NULL) , m_CallbackHandle(0) , m_ScrollSiteCallbackHandle(0) , m_pMouseInSite(0) , m_pScheduler(0) , m_bRecomputeClipScheduled(FALSE) , m_bForceRedrawNeeded(FALSE) , m_bInFullScreen(FALSE) , m_bSettingDisplayMode(FALSE) , m_bRepaintScheduled(FALSE) , m_bDisableForceRedraw(FALSE) , m_bProcessRepaint(FALSE) , m_bAboutToBlt(FALSE) , m_fSharpness(DEF_SHARPNESS) , m_fHue(DEF_HUE) , m_fSaturation(DEF_SATURATION) , m_fContrast(DEF_CONTRAST) , m_fBrightness(DEF_BRIGHTNESS) , m_XSliderPos(0) , m_YSliderPos(0) , m_XSliderRange(0) , m_YSliderRange(0) , m_pTopLevelSite(0) , m_pFocusSite(0) , m_pStatusText(0) , m_nStatusTextExpireTime(0) , m_pCallback(0) , m_pScrollSiteCallback(0) , m_bWasTopMost(FALSE) , m_bDoNotGenerateWMPPaint(FALSE) , m_bSetCaptureOn(FALSE) , m_pCaptureUser(0) , m_pLastUser(0) , m_bModeSharpness(FALSE) , m_nLastMoveTime(0) , m_bAttachWindowPending(FALSE) , m_bDetachWndMsgPending(FALSE) , m_nOldBitsPerPixel(0) , m_nOldHorzRes(0) , m_nOldVertRes(0) , m_Region(NULL) , m_RegionForMouse(NULL) , m_RegionWithoutChildren(NULL) , m_nTransitionState(0) , m_lBltEntryCount(0) , m_bRegionIsValid(FALSE) , m_bTransitionReversed(FALSE) , m_bTransitionTranIn(TRUE) , m_nTransitionVertRepeat(1) , m_nTransitionHorzRepeat(1) , m_nTransitionBorderWidth(0) , m_ulTransitionBorderColor(0) , m_ulTransitionFadeColor(0) , m_bTransitionBlendBorder(FALSE) , m_bTransitionCoordinated(FALSE) , m_bTransitionCoordTranIsParentClip(FALSE) , m_bWindowCreatedByCreate(FALSE) , m_pWindow(NULL) , m_bSiteNeverBlts(FALSE) , m_bCalledComputeClipFromTransition(FALSE) , m_nEventSensitivity(SENSITIVITY_NOT_SET) , m_nDelayFillBorders(0) , m_bUsingList(FALSE) , m_bCompositionLocked(FALSE) , m_bCompositionMode(FALSE) , m_bScheduleUpgrade(FALSE) , m_bVideoUnderTransition(FALSE) , m_bInForceRedraw(FALSE) , m_bSiteRefresh(FALSE) , m_bMoving(FALSE) , m_bTestWindowing(FALSE) , m_nWindowColor(0) , m_bPostageStamp(FALSE) , m_bBltHasBeenCalled(FALSE) , m_pKeyBoardFocusUser(NULL) , m_nTLSMutexLockCount(0) , m_ulTLSMutexOwningThread(0) , m_pDirtyRegion(NULL) , m_bUserWantsSubRects(FALSE) , m_bSiteScalingInfo(FALSE) , m_bScrollingSite(FALSE){ m_fpTransitionEffect = z_TransitionTable[0].m_pSubTypes[0].m_fpTranFunction; //If we are not being aggregated then just point the outer unkown //to ourselves.... if( pUnkOuter == NULL ) { m_pUnkOuter = (IUnknown*)(SiteNonDelegatingUnknown*) this; } // addref the context if( m_pContext ) { m_pContext->AddRef(); // get the CCF m_pContext->QueryInterface(IID_IHXCommonClassFactory, (void**)&m_pCCF); } HX_ASSERT( m_pCCF ); if( m_pCCF ) { m_pCCF->CreateInstance(CLSID_IHXValues, (void**)&m_pValues); HX_ASSERT(m_pValues); } if( m_pContext ) { m_pContext->QueryInterface(IID_IHXScheduler, (void**)&m_pScheduler); } HX_ASSERT(m_pScheduler);#if defined(THREADS_SUPPORTED) || defined(_UNIX_THREADS_SUPPORTED) HXMutex::MakeMutex(m_pMutex); HXThread::MakeThread(m_pDummyThread);#else HXMutex::MakeStubMutex(m_pMutex); HXThread::MakeStubThread(m_pDummyThread);#endif m_pVideoSurface = CBaseSurface::Create(m_pContext, this); m_pVideoSurface->AddRef(); memset(&m_TopLevelWindow, 0, sizeof(HXxWindow)); memset(&m_topleft, 0, sizeof(HXxPoint)); memset(&m_position, 0, sizeof(HXxPoint)); memset(&m_positionOrig, 0, sizeof(HXxPoint)); memset(&m_CreateWindowPos, 0, sizeof(HXxPoint)); memset(&m_size, 0, sizeof(HXxPoint)); memset(&m_screenOffset, 0, sizeof(HXxPoint)); m_pWindow = NULL; memset(&m_rectOldClientRect, 0, sizeof(HXxRect)); memset(&m_rcFocusRect, 0, sizeof(m_rcFocusRect)); m_pTopLevelSite = this; m_bIsChildWindow = TRUE; CreateColorAccess(m_pContext); m_pCallback = new BaseSiteCallback(this); IHXPreferences* pPreferences = NULL; IHXBuffer* pBuffer = NULL; if (HXR_OK == m_pContext->QueryInterface(IID_IHXPreferences,(void**)&pPreferences)) { ReadPrefBOOL(pPreferences, "TestWindowing", m_bTestWindowing); } HX_RELEASE(pPreferences); //Create our dirty rect region. m_pDirtyRegion = HXCreateRegion();#ifdef _CHECK_CREATE {#ifdef _WINDOWS FILE* f1 = fopen("c:\\create.txt", "a+"); /* Flawfinder: ignore */#elif defined(_UNIX) FILE* f1 = fopen("/tmp/create.txt", "a+"); /* Flawfinder: ignore */#endif if( f1 ) { fprintf(f1, "%p Constructor: %p\n", GetCurrentThreadId(), this); fclose(f1); } }#endif}/************************************************************************ * Method: * Destructor */CHXBaseSite::~CHXBaseSite(){ HX_DELETE(m_pMutex); HX_DELETE(m_pDummyThread); m_bInDestructor = TRUE; //Focus if(m_pTopLevelSite->GetFocusSite() == this) { m_pTopLevelSite->SetFocusSite(NULL); } //Clean up the color access functions HX_DELETE(zm_pColorAcc); //Cleanup Mouse oversupport if (m_pTopLevelSite->m_pMouseInSite == this) { m_pTopLevelSite->m_pMouseInSite = NULL; } //Cleanup all remaining callbacks if (m_CallbackHandle) { m_pScheduler->Remove(m_CallbackHandle); m_CallbackHandle = 0; } HX_DELETE(m_pCallback); if (m_ScrollSiteCallbackHandle) { m_pScheduler->Remove(m_ScrollSiteCallbackHandle); m_ScrollSiteCallbackHandle = 0; } HX_DELETE(m_pScrollSiteCallback); //Clean up all child sites while(m_ChildrenMap.GetCount()) { IHXSite* pSite = NULL; pSite = (IHXSite*) (m_ChildrenMap.Begin()).get_key(); DestroyChild(pSite); } m_ChildrenInZOrder.RemoveAll(); //clean up passive site watchers while(m_PassiveSiteWatchers.GetCount()) { IHXPassiveSiteWatcher* pWatcher = (IHXPassiveSiteWatcher*)m_PassiveSiteWatchers.GetHead(); HX_RELEASE(pWatcher); m_PassiveSiteWatchers.RemoveHead(); } //Check and see if we are in the YUV Site list. If so, remove ourselves. LISTPOSITION pPos = zm_YUVSiteList.Find(this); if(pPos) { zm_YUVSiteList.RemoveAt(pPos); } _EmptyBlenderList(); _EmptyNotifierList(); //Remove all pending tasks. if (m_pTopLevelSite) m_pTopLevelSite->RemovePendingTasks(this); // release intefaces HX_RELEASE(m_pCCF); HX_RELEASE(m_pScheduler); HX_RELEASE(m_pContext); HX_RELEASE(m_pValues); HX_RELEASE(m_pVideoSurface); HX_RELEASE(m_pRootSurface); if(m_pTopLevelSite != this) HX_RELEASE(m_pTopLevelSite); HXDestroyRegion(m_Region); m_Region=NULL; HXDestroyRegion(m_RegionForMouse); m_RegionForMouse=NULL; HXDestroyRegion(m_RegionWithoutChildren); m_RegionWithoutChildren = NULL;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -