void LLViewerMediaImpl::setVisible(bool visible) { LLPluginClassMedia* plugin = getMediaPlugin(); mVisible = visible; if(mVisible) { if(plugin && plugin->isPluginExited()) { destroyMediaSource(); } if(!plugin) { createMediaSource(); } } if(plugin) { plugin->setPriority(mVisible?LLPluginClassBasic::PRIORITY_NORMAL:LLPluginClassBasic::PRIORITY_SLEEP); } }
void LLViewerMediaImpl::update() { LLPluginClassMedia* plugin = getMediaPlugin(); if (!plugin) { return; } plugin->idle(); if (plugin->isPluginExited()) { destroyMediaSource(); return; } if (!plugin->textureValid()) { return; } if(mSuspendUpdates || !mVisible) { return; } LLViewerTexture* placeholder_image = updatePlaceholderImage(); if(placeholder_image) { LLRect dirty_rect; if (plugin->getDirty(&dirty_rect)) { // Constrain the dirty rect to be inside the texture S32 x_pos = llmax(dirty_rect.mLeft, 0); S32 y_pos = llmax(dirty_rect.mBottom, 0); S32 width = llmin(dirty_rect.mRight, placeholder_image->getWidth()) - x_pos; S32 height = llmin(dirty_rect.mTop, placeholder_image->getHeight()) - y_pos; if(width > 0 && height > 0) { U8* data = plugin->getBitsData(); // Offset the pixels pointer to match x_pos and y_pos data += ( x_pos * plugin->getTextureDepth() * plugin->getBitsWidth() ); data += ( y_pos * plugin->getTextureDepth() ); placeholder_image->setSubImage( data, plugin->getBitsWidth(), plugin->getBitsHeight(), x_pos, y_pos, width, height, TRUE); // force a fast update (i.e. don't call analyzeAlpha, etc.) } plugin->resetDirty(); } } }