📄 mrtwin.cpp
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: mrtwin.cpp,v 1.1.2.1 2004/07/09 01:50:38 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 ***** *////////////////////////////////////////////////////////////////////////////////// mrtwin.cpp //// (Macintosh version of RTWIN.cpp)//// Function:// BOOL OnPaint(TextWindow* pTextWindow, void* pDC, void* pPaintstruct,// BOOL bSomeonesBeginOrEndTimeWasCrossedOverSinceLastDraw,// INT16 xScrollWindowAmt, INT16 yScrollWindowAmt);//// Purpose:// This function does the actual rendering of text by doing a TextOut() of// all text in all TextContainers in the TextContainerList of pTextWindow// whose text is visible in the rectangle to be updated// This Function is called from WM_PAINT and hdc and ps are from// BeginPaint(); ps holds the invalid rectangle to be updated: //// Returns:// Returns FALSE on error, TRUE otherwise. //////// Function:// BOOL PaintBackground(TextWindow* pTextWindow, void* pPaintstruct)//// Purpose:// This function paints the background of the window at the given rectangle// of pPaintstruct.// This Function is called from WM_PAINT, and pPaintstruct is (in Windows)// from BeginPaint(); pPaintstruct holds the invalid rectangle to be// painted.//// Returns:// Returns FALSE on error, TRUE otherwise. //#include "hxtypes.h"#include "hxassert.h"#include "hxslist.h"#include "hxstack.h"#include "chxxtype.h"#include "rt_types.h"#include "txtattrb.h"#include "txtcntnr.h"#include "textline.h"#include "txtwindw.h"#if defined(_GETCHARSET_)#error#endif#include "atotime.h" //for live time comparison: IsTimeAMoreRecentThanTimeB()#include "rtwin.h"#include "atocolor.h"#include "fontdefs.h"#include "fontinfo.h"#include "textprsr.h" /* for REAL_TEXT_TRANSPARENT_BGCOLOR_MAJOR_VERSION + ... */#ifndef _MAC_MACHO#include "ugworld.h"#include "udstate.h"#endif#include "hxcom.h"#include "hxvsurf.h" // for IHXVideoSurface#include "hxevent.h" // for HX_SURFACE_UPDATE#include "textprsr.h" /*for ..._CONTENT_VERSION_... defines */#ifndef _MAC_MACHO#include <Quickdraw.h>#endif#ifndef _MAC_MACHO#include "udutils.h" // to get topLeft and botRight macros#endif#include "platform/mac/maclibrary.h" // for DWORD definition#include "hxheap.h"#ifdef _DEBUG#undef HX_THIS_FILE static char HX_THIS_FILE[] = __FILE__;#endif//Characters of the same font and height in Mac tend to be wider// than on Windows (from which the char-width tables were derived),// so we need to draw with a slightly smaller character so they don't// crowd each other out. 0.875 = 14/16, i.e., 16pt font will be// drawn with 14-pt characters: #define MACINTOSH_RT_FONT_TEXTSIZE_FUDGE_FACTOR 0.875#define FONTFACE_BUF_SIZE 32UINT16 Convert8BitTo16Bit(UINT8 x){ float factor=((float)x)/255; long returnValue=(factor*65535); return returnValue;}//// Converts a Windows COLORTYPE into an RGBColor type.//void ConvertCOLORTYPEtoRGBColor(RGBColor& rgbColor, COLORTYPE colorVal){ char* x=(char*)&colorVal; rgbColor.red =(short)Convert8BitTo16Bit(x[1]); rgbColor.green =(short)Convert8BitTo16Bit(x[2]); rgbColor.blue =(short)Convert8BitTo16Bit(x[3]);}/////////////////////////////////////////////////////////////////////////////// Function:// BOOL// OnPaint// (// TextWindow* pTextWindow,// void* pDC,// void* pPaintstruct// )//// Purpose:// This function does the actual rendering of text by doing a TextOut() of// all text in all TextContainers in the TextContainerList of pTextWindow// whose text is visible in the rectangle to be updated// This Function is called from WM_PAINT and hdc and ps are from// BeginPaint(); ps holds the invalid rectangle to be updated: //// Returns:// Returns FALSE on error, TRUE otherwise. //BOOL OnPaint(TextWindow* pTextWindow, void* pvoidEvent, void* pPaintstruct, ULONG32 ulTimeOfCurrentDraw, BOOL bSomeonesBeginOrEndTimeWasCrossedOverSinceLastDraw, INT16 iXScrollWindowAmt, INT16 iYScrollWindowAmt){ HX_ASSERT_VALID_PTR(pTextWindow); if(!pTextWindow) { return FALSE; } BOOL b_FunctionSucceeded = TRUE; LONG32 lWindowWidth = pTextWindow->getWindowWidth(); LONG32 lWindowHeight = pTextWindow->getWindowHeight(); BOOL bChromaKeyWasAppliedToBg = FALSE; BOOL bChromaKeyWasAppliedToSomeText = FALSE; HXxEvent* pEvent = (HXxEvent*)pvoidEvent; HX_ASSERT(pEvent); ULONG32 listSize = pTextWindow->textCntnrListSize(); //get real rect to draw into - don't draw into entire window Rect updateRect; ::SetRect(&updateRect, 0, 0, pTextWindow->getWindowWidth(), pTextWindow->getWindowHeight()); #if defined(DO_CPU_FRIENDLY_SCROLLING) // /Fixes background-not-being-completely-drawn part of PR 85479; make // sure we draw in entire offscreen area which is 1.5 * (w or h) depending // on direction of motion: if (pTextWindow->getCrawlRate() && !pTextWindow->getScrollRate()) { updateRect.right += pTextWindow->getWindowWidth()/2; } else if (!pTextWindow->getCrawlRate() && pTextWindow->getScrollRate()) { updateRect.bottom += pTextWindow->getWindowHeight()/2; }#endif /* defined(DO_CPU_FRIENDLY_SCROLLING) */ // /XXXEH- use the following if and when the core starts doing // subrects on the Mac: CHXxRect* pDestRect = pEvent? (CHXxRect*)((HXxEvent*)pvoidEvent)->param2 : NULL; UINT32 ulEffectiveFgOpacity = pTextWindow->getMediaOpacity(); UINT32 ulEffectiveBgOpacity = pTextWindow->getBackgroundOpacity(); UINT32 ulChromaKey = pTextWindow->getChromaKey(); UINT32 ulChromaKeyTolerance = pTextWindow->getChromaKeyTolerance(); UINT32 ulChromaKeyOpacity = pTextWindow->getChromaKeyOpacity(); #if defined(DO_CPU_FRIENDLY_SCROLLING) BOOL bDoingScrollOfRect = FALSE; if(!bSomeonesBeginOrEndTimeWasCrossedOverSinceLastDraw && (iXScrollWindowAmt>0 || iYScrollWindowAmt>0) // /XXXEH- no CPU-friendly *diagonal* motion, yet, since // we don't support that in Windows player and it doesn't // work perfectly yet on the Mac: && !(iXScrollWindowAmt>0 && iYScrollWindowAmt>0)) { bDoingScrollOfRect = TRUE; }#endif /* defined(DO_CPU_FRIENDLY_SCROLLING) */ { GWorldPtr theMacGWorld; CGrafPtr theSavePort; GDHandle theSaveDevice; Rect theBounds = updateRect; { ::GetGWorld(&theSavePort, &theSaveDevice); RGBColor theForeColor, theBackColor; ::GetForeColor(&theForeColor); ::GetBackColor(&theBackColor); RgnHandle theClipRgn = ::NewRgn(); ::GetClip(theClipRgn); theMacGWorld = NULL; Rect gwRect = theBounds; Point topLeft; Point botRight; topLeft.h = gwRect.left; topLeft.v = gwRect.top; botRight.h = gwRect.right; botRight.v = gwRect.bottom; LocalToGlobal(&topLeft); LocalToGlobal(&botRight); gwRect.left = topLeft.h; gwRect.top = topLeft.v; gwRect.right = botRight.h; gwRect.bottom = botRight.v;#if defined(DO_CPU_FRIENDLY_SCROLLING) theMacGWorld = pTextWindow->m_pOffScreenWorld;#else QDErr err = ::NewGWorld(&theMacGWorld, 32, &gwRect, NULL, NULL, useTempMem);#endif /* defined(DO_CPU_FRIENDLY_SCROLLING) */ if (theMacGWorld) { ::SetGWorld(theMacGWorld, NULL); ::SetOrigin(theBounds.left, theBounds.top); ::SetClip(theClipRgn); ::LockPixels((::GetGWorldPixMap(theMacGWorld))); ::RGBForeColor(&theForeColor); ::RGBBackColor(&theBackColor); } ::DisposeRgn(theClipRgn); } COLORTYPE backColorType = pTextWindow->getBackgroundColor();#if defined (HANDLE_TRANSPARENT_WINDOW_BACKGROUND) BOOL bDrawBackgroundAsTransparent = FALSE; // /XXXEH- We need to revisit this and deal with transparent alpha // channel here properly rather than just skipping drawing: // /Putting parens around the two parts of this if() that are on either // side of the '||' helps fix PR 85479 (horizontal-motion version): if ((TRANSPARENT_COLOR == backColorType) && ( (pTextWindow->getMajorContentVersion() > REAL_TEXT_TRANSPARENT_BGCOLOR_MAJOR_VERSION) || (pTextWindow->getMajorContentVersion() == REAL_TEXT_TRANSPARENT_BGCOLOR_MAJOR_VERSION && pTextWindow->getMinorContentVersion() >= REAL_TEXT_TRANSPARENT_BGCOLOR_MINOR_VERSION) ) ) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -