⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtwin.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: rtwin.cpp,v 1.1.2.1 2004/07/09 01:50:45 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 ***** *////////////////////////////////////////////////////////////////////////////////// RTWIN.CPP//// Function://  BOOL OnPaint(TextWindow* pTextWindow, void* pDC, void* pPaintstruct,//	    ULONG32 ulTimeOfCurrentDraw,//	    BOOL SomeonesBeginOrEndTimeWasCrossedOverSinceLastDraw,//	    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" /*Must be included before windows.h for VC6 compiler*/#if defined(_WINDOWS)#include <windows.h>#endif#include "hxassert.h"#include "hxstack.h"#include "hxslist.h"#include "rt_types.h" //for _CHAR, RED_GREEN_OR_BLUE, COLORTYPE#include "fontdefs.h"#include "txtattrb.h"#include "txtcntnr.h"#include "textline.h"#include "atocolor.h"#include "fontinfo.h" //for GetCharacterWidth().#include "atotime.h" //for live time comparison: IsTimeAMoreRecentThanTimeB()#include "chxxtype.h"#include "txtwindw.h" //for class TextWindow.#include "hxcom.h"#include "hxvsurf.h"#include "textprsr.h" /* for REAL_TEXT_TRANSPARENT_BGCOLOR_MAJOR_VERSION + ... */// /#define USE_FREETYPE_DIRECTLY#if defined (USE_FREETYPE_DIRECTLY)#if defined(_WINDOWS)#include "../textsvcs.h"#elif defined(_MACINTOSH)#include "textsvcs.h"#endif#endif /* END: USE_FREETYPE_DIRECTLY. */#if defined(_WINDOWS)#include "../rtwin.h"#elif defined(_MACINTOSH)#include "rtwin.h"#endif#include "hxheap.h"#ifdef _DEBUG#undef HX_THIS_FILE		static char HX_THIS_FILE[] = __FILE__;#endif#if defined(_DEBUG)// /#define XXXEH_TESTING_DATAURLPLAINTEXT_HANDLING2#endifCOLORREF convertCOLORTYPEtoWinBGRColor(	COLORTYPE RGBVal){    COLORREF winColor = 0L;    RED_GREEN_OR_BLUE red, green, blue;    red = (RED_GREEN_OR_BLUE)(RGBVal>>16); //red is bytes 4,5    green = (RED_GREEN_OR_BLUE)(RGBVal>>8); //green is 2,3    blue = (RED_GREEN_OR_BLUE)RGBVal; //and blue is bytes 0,1    winColor = (COLORREF)red | (COLORREF(green)<<8) | 	    (COLORREF(blue)<<16);     return winColor;}/////////////////////////////////////////////////////////////////////////////// Function://  BOOL//  OnPaint//  (//	TextWindow* pTextWindow,//	void* pDC,//	void* pPaintstruct,//	ULONG32 ulTimeOfCurrentDraw//  )//// 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* pVoid, void* pPaintstruct,	ULONG32 ulTimeOfCurrentDraw,	BOOL SomeonesBeginOrEndTimeWasCrossedOverSinceLastDraw,	INT16 xScrollWindowAmt, INT16 yScrollWindowAmt){    HX_ASSERT_VALID_PTR(pTextWindow);    HX_ASSERT(pVoid);    HX_ASSERT_VALID_PTR(pPaintstruct);    if(!pTextWindow  ||  !pVoid  ||  !pPaintstruct	    ||  !pTextWindow->m_hBitmap)    {	return FALSE;    }    // Initialize chromaKey flag. If the background    // color is the same as the chroma key, then we     // know we are applying the chroma key. Also, when    // we draw text of a certain color later down in    // this method, we may be setting this flag, depending    // on the text color.    BOOL bChromaKeyWasApplied = FALSE;    if (pTextWindow->isChromaKeySet())    {        if (DoesChromaKeyMatch(pTextWindow->getBackgroundColor(),                               pTextWindow->getChromaKey(),                               pTextWindow->getChromaKeyTolerance()))        {            if (pTextWindow->getChromaKeyOpacity() < 255)            {                bChromaKeyWasApplied = TRUE;            }        }    }    LONG32 lWindowWidth = pTextWindow->getWindowWidth();    LONG32 lWindowHeight = pTextWindow->getWindowHeight();        PAINTSTRUCT ps = *((PAINTSTRUCT*)pPaintstruct);#if !defined(USE_DIB_SECTION)    HBITMAP hbmpOld;#endif    BOOL b_FunctionSucceeded = TRUE;    RECT updateRect = ps.rcPaint;    //Due to window-offset-in-layout problem,    // we need to translate the rect by the upperleftX,Y of pTextWindow:    updateRect.left -= pTextWindow->getUpperLeftX();    updateRect.top -= pTextWindow->getUpperLeftY();    ULONG32 listSize = pTextWindow->textCntnrListSize();        if(!pTextWindow->m_pDeviceContextMemory)    {	return FALSE;	    }    HDC	hDC = (HDC)pTextWindow->m_pDeviceContextMemory;#if !defined(USE_DIB_SECTION)    hbmpOld = (HBITMAP)SelectObject(hDC,	    (HBITMAP)pTextWindow->m_pBmpCompat);    if(!hbmpOld)    {	return FALSE;    }#endif    BOOL bDoingScrollOfRect = FALSE;    if(!SomeonesBeginOrEndTimeWasCrossedOverSinceLastDraw  &&	    (xScrollWindowAmt>0  ||  yScrollWindowAmt>0)	    //XXXEH- no CPU-friendly diagonal motion, yet, due to	    // strange behavior in drawing in rtwin with lImageOffset	    // not being calculated to take into account the extra	    // width bytes:	    &&  !(xScrollWindowAmt>0  &&  yScrollWindowAmt>0))    {#if defined(SCROLLINGVERSION_SCROLLDC)	RECT rectScroll;	RECT rectClip;	rectScroll.left = 0;	rectScroll.top = 0;	rectScroll.right = lWindowWidth +		(xScrollWindowAmt>0? lWindowWidth/2 : 0);	//FONT_SIZE_PLUS4 is max height of new char, so no	// need to scroll beyond since nothing will have been	// drawn beyond yet:	rectScroll.bottom = lWindowHeight + FONT_SIZE_PLUS4;	rectClip.left = 0;	rectClip.top = 0;	rectClip.right = lWindowWidth +		(xScrollWindowAmt>0? lWindowWidth/2 : 0);	rectClip.bottom = lWindowHeight + FONT_SIZE_PLUS4;	ScrollDC(hDC,		-xScrollWindowAmt, -yScrollWindowAmt,		&rectScroll, &rectClip, NULL, NULL);#endif	bDoingScrollOfRect = TRUE;    }#if defined(XXXEH_TESTING_DATAURLPLAINTEXT_HANDLING2)FILE* f1 = ::fopen("c:\\LogDataURLhandling.txt", "a+");::fprintf(f1, "Draw(), just before PaintBackground (listsize=%lu)\n", listSize);::fclose(f1);#endif    if(!bDoingScrollOfRect  &&	    !PaintBackground(pTextWindow, pPaintstruct))    {#if !defined(USE_DIB_SECTION)	SelectObject(hDC, hbmpOld);#endif	return FALSE;    }    #if defined (USE_FREETYPE_DIRECTLY)/* XXXEH- moved the following block (up to "END XXXEH-0") for cross-plat use *  vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv *    // /Moved this code up from under the below while loop so we can pass pBits    // to ApplyTextOpacity() instead of doing the same code over and over    // inside ApplyTextOpacity(); that'll make ApplyTextOpacity() be cross-    // platform, as well (and it can be moved out so all plats can use it):#if !defined(USE_DIB_SECTION)    // retreive the bitmap handler    HBITMAP hBM = (HBITMAP)SelectObject(hDC, hbmpOld);#endif /* !USE_DIB_SECTION. */    UCHAR*  pBits = NULL;    LPBITMAPINFOHEADER pHeader = NULL;    CHXxRect* pDestRect = (CHXxRect*)((HXxEvent*)pVoid)->param2;    CHXxRect srcRect(0, 0, lWindowWidth, lWindowHeight);    CHXxRect destRect;        LONG32 lImageOffset = 0L;    LONG32 lSavedHeaderHeight = -1;#if !defined(USE_DIB_SECTION)    // convert HBITMAP to DIB:    if (pTextWindow->m_hDIB &&	HXR_OK == pTextWindow->m_hDIB->GetDIBits(hDC, hBM, pBits, pHeader))    {				    #else //USE_DIB_SECTION:    //we already have a DIB, so use it:    if(pTextWindow->m_pBits)    {	pBits = (UCHAR*)(pTextWindow->m_pBits);	pHeader = &(pTextWindow->m_BITMAPINFOHEADER);#endif /* USE_ else !USE_ DIB_SECTION. */#if defined(SCROLLINGVERSION_SCROLL_BY_MOVING_WINDOW)	if(bDoingScrollOfRect)	{	    if(xScrollWindowAmt>0)	    {		srcRect.left += xScrollWindowAmt;		srcRect.right += xScrollWindowAmt;	    }	    if(yScrollWindowAmt>0)	    {		//Note: we have to subtract, not add, because DIB's origin is		// bottom left, not top left:		srcRect.top += yScrollWindowAmt;		srcRect.bottom += yScrollWindowAmt;	    }	}	//Keep the offscreen height so we can reset it after doing the Blt():	lSavedHeaderHeight = pHeader->biHeight;	//If we're just using part of a larger offscreen area, then we need to	// send an offset into the buffer that accounts for the extra vertical	// lines of data (which, in Windows, byte 0 of the data is the first	// byte of the LAST scan line, i.e., starts line # pBitmapInfo->biHeight):	if(pHeader->biHeight != srcRect.Height())	{	    lImageOffset =		    (pHeader->biHeight - srcRect.Height() - srcRect.top) *		    (pHeader->biBitCount / 8) * pHeader->biWidth;	    if(lImageOffset > 0L)	    {		if(srcRect.top != 0)		    srcRect.bottom -= srcRect.top;		srcRect.top = 0;		pHeader->biHeight = srcRect.Height();		pHeader->biSizeImage = WIDTHBYTES((pHeader->biWidth * 			pHeader->biBitCount) * pHeader->biHeight);	    }	    else	    {		lImageOffset = 0L;	    }	}#endif /* SCROLLINGVERSION_SCROLL_BY_MOVING_WINDOW. */	if (pDestRect)	{	    destRect.SetRect(pDestRect->left, 			     pDestRect->top, 			     pDestRect->right,			     pDestRect->bottom);	}	else	{	    destRect.SetRect(0,			     0,			     lWindowWidth, 			     lWindowHeight);	}/* END XXXEH-0. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/#endif /* USE_FREETYPE_DIRECTLY. */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -