pxgifrnd.cpp
来自「symbian 下的helix player源代码」· C++ 代码 · 共 1,936 行 · 第 1/5 页
CPP
1,936 行
retVal = m_pValues->GetPropertyBuffer(pName, rpVal);
}
return retVal;
}
STDMETHODIMP CGIFRenderer::GetFirstPropertyBuffer(REF(const char*) rpName, REF(IHXBuffer*) rpVal)
{
HX_RESULT retVal = HXR_FAIL;
if (m_pValues)
{
retVal = m_pValues->GetFirstPropertyBuffer(rpName, rpVal);
}
return retVal;
}
STDMETHODIMP CGIFRenderer::GetNextPropertyBuffer(REF(const char*) rpName, REF(IHXBuffer*) rpVal)
{
HX_RESULT retVal = HXR_FAIL;
if (m_pValues)
{
retVal = m_pValues->GetNextPropertyBuffer(rpName, rpVal);
}
return retVal;
}
STDMETHODIMP CGIFRenderer::SetPropertyCString(const char* pName, IHXBuffer* pVal)
{
HX_RESULT retVal = HXR_FAIL;
if (m_pValues)
{
// Check for the default SMIL namespace
BOOL bUpdateNeeded = FALSE;
if (!strcmp(pName, "SMILDefaultNamespace"))
{
if (m_ulBackgroundOpacity != 0)
{
bUpdateNeeded = TRUE;
}
m_ulBackgroundOpacity = 0;
// Update the background color
UINT32 ulBgAlpha = 255 - m_ulBackgroundOpacity;
m_ulBackgroundColor = (m_ulBackgroundColor & 0x00FFFFFF) |
((ulBgAlpha << 24) & 0xFF000000);
}
// Do we need to update the display buffer
if (bUpdateNeeded && !m_bImageBombed)
{
// If we haven't received our first time sync yet
// (m_bFirstTimeSync == TRUE), then all we need to do
// is redraw the transparent background color into the
// the display buffer. If we have already received our
// first time sync, then we need to redraw the entire buffer,
// including redrawing the frames
if (m_bFirstTimeSync)
{
// We haven't draw any frames into our display buffer
// yet, so all we have to do is redraw a transparent
// background color into the buffer.
DrawBackgroundColor();
// We definitely will be using the alpha channel
m_bUsesAlphaChannel = TRUE;
}
else
{
if (m_pGIFCodec && m_pOutputBuffer)
{
// Compute the current frame we are on (note that
// m_ulCurImg contains the index of the NEXT frame
// that we are about to draw
UINT32 ulCurFrame = (m_ulCurImg > 0 ? m_ulCurImg - 1 : 0);
// Update the buffer
// XXXMEH - optimization for later. In some cases if we
// just changed the media opacity, then it may not be necessary
// to start back at the beginning and rebuild the frame buffer
// from the first frame.
m_pGIFCodec->GetRGBImageEx(-1,
ulCurFrame,
m_pOutputBuffer->GetBuffer(),
m_pGIFCodec->GetLogicalScreenWidth(),
m_pGIFCodec->GetLogicalScreenHeight(),
m_ulPadWidth,
m_ulBytesPerPixel,
m_bRowsInverted,
m_bRGBOrdering,
m_ulBackgroundColor,
(m_ulMediaOpacity == 255 ? FALSE : TRUE),
m_ulMediaOpacity,
m_bMediaChromaKeySpecified,
m_ulMediaChromaKey,
m_ulMediaChromaKeyTolerance,
m_ulMediaChromaKeyOpacity);
// XXXMEH - do dumb assignment for now. We should later check
// chroma key to find if any colors were actually encountered.
if (m_ulBackgroundOpacity < 255 ||
m_ulMediaOpacity < 255 ||
m_bMediaChromaKeySpecified)
{
m_bUsesAlphaChannel = TRUE;
}
}
}
}
retVal = m_pValues->SetPropertyCString(pName, pVal);
}
return retVal;
}
STDMETHODIMP CGIFRenderer::GetPropertyCString(const char* pName, REF(IHXBuffer*) rpVal)
{
HX_RESULT retVal = HXR_FAIL;
if (m_pValues)
{
retVal = m_pValues->GetPropertyCString(pName, rpVal);
}
return retVal;
}
STDMETHODIMP CGIFRenderer::GetFirstPropertyCString(REF(const char*) rpName, REF(IHXBuffer*) rpVal)
{
HX_RESULT retVal = HXR_FAIL;
if (m_pValues)
{
retVal = m_pValues->GetFirstPropertyCString(rpName, rpVal);
}
return retVal;
}
STDMETHODIMP CGIFRenderer::GetNextPropertyCString(REF(const char*) rpName, REF(IHXBuffer*) rpVal)
{
HX_RESULT retVal = HXR_FAIL;
if (m_pValues)
{
retVal = m_pValues->GetNextPropertyCString(rpName, rpVal);
}
return retVal;
}
STDMETHODIMP CGIFRenderer::UpdatePacketTimeOffset(INT32 lTimeOffset)
{
HX_RESULT retVal = HXR_OK;
// Save the time offset
// XXXMEH - should this be negative
m_lTimeOffset = -lTimeOffset;
return retVal;
}
/************************************************************************
* Method:
* IHXUpdateProperties::UpdatePlayTimes
* Purpose:
* Call this method to update the playtime attributes
*/
STDMETHODIMP
CGIFRenderer::UpdatePlayTimes(IHXValues* pProps)
{
return HXR_OK;
}
STDMETHODIMP CGIFRenderer::HandleCallback(UINT32 ulSchedulerTime, UINT32 ulInstance)
{
HX_RESULT retVal = HXR_OK;
if (!m_bPaused)
{
// Get the current scheduler time
HXTimeval cTime = m_pScheduler->GetCurrentSchedulerTime();
// Compute the difference in scheduler time
UINT32 ulSchedDiff = GetTimevalDiff(m_tSchedulerTimeBase, cTime);
// Compute the time in our timeline
UINT32 ulTime = m_ulTimeAtSchedulerTimeBase + ulSchedDiff;
// Update the display (if necessary)
retVal = UpdateDisplay(ulTime);
}
return retVal;
}
STDMETHODIMP CGIFRenderer::CASOnPosLength(UINT32 ulPosition, UINT32 ulLength)
{
HX_RESULT retVal = HXR_OK;
// XXXMEH
// char szDbgStr[128];
// DEBUGPRINTF(szDbgStr, "CGIFRenderer::CASOnPosLength(%lu,%lu) tick=%lu\n",
// ulPosition, ulLength, HX_GET_BETTERTICKCOUNT());
if (m_bPaused)
{
// Clear the paused flag
m_bPaused = FALSE;
// Adjust the time according to the
// offset passed in through OnPacket()
INT32 lAdjustedTime = ((INT32) ulPosition) + m_lTimeOffset;
UINT32 ulAdjustedTime = (UINT32) (lAdjustedTime >= 0 ? lAdjustedTime : 0);
// Set the current scheduler time base
if (m_pScheduler)
{
// Compute time in milliseconds
m_tSchedulerTimeBase = m_pScheduler->GetCurrentSchedulerTime();
m_ulTimeAtSchedulerTimeBase = ulAdjustedTime;
}
// Update the display
UpdateDisplay(ulAdjustedTime);
}
return retVal;
}
STDMETHODIMP CGIFRenderer::CASOnPresentationOpened()
{
HX_RESULT retVal = HXR_OK;
return retVal;
}
STDMETHODIMP CGIFRenderer::CASOnPresentationClosed()
{
HX_RESULT retVal = HXR_OK;
return retVal;
}
STDMETHODIMP CGIFRenderer::CASOnStatisticsChanged()
{
HX_RESULT retVal = HXR_OK;
return retVal;
}
STDMETHODIMP CGIFRenderer::CASOnPreSeek(ULONG32 ulOldTime, ULONG32 ulNewTime)
{
HX_RESULT retVal = HXR_OK;
return retVal;
}
STDMETHODIMP CGIFRenderer::CASOnPostSeek(ULONG32 ulOldTime, ULONG32 ulNewTime)
{
HX_RESULT retVal = HXR_OK;
return retVal;
}
STDMETHODIMP CGIFRenderer::CASOnStop()
{
HX_RESULT retVal = HXR_OK;
return retVal;
}
STDMETHODIMP CGIFRenderer::CASOnPause(ULONG32 ulTime)
{
MLOG_MISC(m_pErrorMessages,
"0x%08x::CASOnPause(%lu)\n",
this, ulTime);
HX_RESULT retVal = HXR_OK;
m_bPaused = TRUE;
return retVal;
}
STDMETHODIMP CGIFRenderer::CASOnBegin(ULONG32 ulTime)
{
MLOG_MISC(m_pErrorMessages,
"0x%08x::CASOnBegin(%lu)\n",
this, ulTime);
HX_RESULT retVal = HXR_OK;
return retVal;
}
STDMETHODIMP CGIFRenderer::CASOnBuffering(ULONG32 ulFlags, UINT16 unPercentComplete)
{
HX_RESULT retVal = HXR_OK;
return retVal;
}
STDMETHODIMP CGIFRenderer::CASOnContacting(const char* pHostName)
{
HX_RESULT retVal = HXR_OK;
return retVal;
}
void CGIFRenderer::OnMouseMove(INT16 fwKeys, INT16 xPos, INT16 yPos)
{
// Make sure we're up and running
if (!m_pGIFCodec)
{
return;
}
// don't do anything if the x/y coordinates have changed from the
// last call to OnMouseMove - this is needed because the call to
// IHXStatusMessage::SetStatus() results in a WM_MOUSEMOVE event
if(xPos == m_sOldMouseX && yPos == m_sOldMouseY)
{
return;
}
m_sOldMouseX = xPos;
m_sOldMouseY = yPos;
#if defined(_WINDOWS)
HCURSOR hCurrentCursor = GetCursor();
#endif
if (xPos >= 0 && xPos < (INT16) m_pGIFCodec->GetLogicalScreenWidth() &&
yPos >= 0 && yPos < (INT16) m_pGIFCodec->GetLogicalScreenHeight() &&
m_cURL.length() > 0) // we have a link
{
// We ARE over a hyperlink
#if defined(_WINDOWS)
if(!m_hHyperlinkCursor)
{
m_hHyperlinkCursor = LoadCursor(g_hInstance, MAKEINTRESOURCE(HANDCURSOR));
if(!m_hHyperlinkCursor)
{
m_hHyperlinkCursor = LoadCursor(NULL, IDC_UPARROW);
}
}
if(m_hHyperlinkCursor && hCurrentCursor != m_hHyperlinkCursor)
{
// We're over a link and the cursor is NOT already the hyperlink cursor,
// so change it. This will happen when we get a WM_SETCURSOR event
m_bSetHyperlinkCursor = TRUE;
}
#elif defined(_MACINTOSH)
if (m_hHyperlinkCursor)
{
::SetCursor(*m_hHyperlinkCursor);
m_eCurrentCursor = CURSOR_HYPERLINK;
}
#elif defined(_UNIX) && defined(USE_XWINDOWS)
if (m_hCurrentCursor == -1 && m_pDisplay && m_Window && m_hHyperlinkCursor != -1)
{
XLockDisplay(m_pDisplay);
XDefineCursor(m_pDisplay, m_Window, m_hHyperlinkCursor);
XUnlockDisplay(m_pDisplay);
m_hCurrentCursor = m_hHyperlinkCursor;
}
#endif
if (m_pStatusMessage)
{
m_bStatusMsgWillNeedErasing = TRUE;
m_pStatusMessage->SetStatus(m_cURL.c_str());
}
}
else
{
// We are NOT over a hyperlink
#if defined(_WINDOWS)
if(hCurrentCursor == m_hHyperlinkCursor)
{
// We are not over a hyperlink and out cursor IS the hyperlink cursor,
// so we need to change it back. This will happen when we get a WM_SETCURSOR event
m_bSetHyperlinkCursor = FALSE;
}
#elif defined(_MACINTOSH)
if (m_eCurrentCursor == CURSOR_HYPERLINK)
{
::InitCursor();
m_eCurrentCursor = CURSOR_ARROW;
}
#elif defined(_UNIX) && defined(USE_XWINDOWS)
if (m_hCurrentCursor ==
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?