私はビデオストリーミング用に NPAPI を使用しています。
ただし、Mac Safari (Mt.Lion、v6.0.2) では、読み込み時に CPU 使用率が高くなります (7~80%)。Chrome または FireFox は正常です。
NPNFuncs.invalidaterect 関数を呼び出すと思います。
int16_t PLUGINAPI::handleEvent(void* event)
{
NPCocoaEvent* cocoaEvent = (NPCocoaEvent*)event;
ScriptablePluginObject* pObject = (ScriptablePluginObject*)m_pScriptableObject;
if(cocoaEvent->type == NPCocoaEventDrawRect) {
CGContextRef cgContext = cocoaEvent->data.draw.context;
if(!cgContext)
return true;
//Add rect and translate the video
CGContextAddRect(cgContext, CGRectMake (0, 0, m_Window->width, m_Window->height));
CGContextTranslateCTM(cgContext, 0, m_Window->height);
CGContextScaleCTM(cgContext, 1.0, -1.0);
//Display the video here
if(pObject && pObject->m_pNpapiPlugin)
pObject->m_pNpapiPlugin->WEBVIEWER_DisplayFrame(cgContext, m_Window->width, m_Window->height);
//Fulsh cgcontextref
CGContextFlush(cgContext);
//Generate DrawRect event
NPRect rect = {0, 0, m_Window->height, m_Window->width};
NPNFuncs.invalidaterect(m_pNPInstance, &rect);
NPNFuncs.forceredraw(m_pNPInstance);
} else {
if(pObject && pObject->m_pNpapiPlugin)
pObject->m_pNpapiPlugin->WEBVIEWER_SendEvent(cocoaEvent);
}
return true;
}
プラグイン描画の別の方法はありますか? または、この問題の解決策が必要です。