BOOL LLWebBrowserTexture::render() { if(updateBrowserTexture()) { // updateBrowserTexture already verified that the media plugin is there and the texture is valid. LLPluginClassMedia* media_plugin = mMediaSource->getMediaPlugin(); LLRect dirty_rect; if(mNeedsUpdate) { // If we need an update, use the whole rect instead of the dirty rect. dirty_rect.mLeft = 0; dirty_rect.mBottom = 0; dirty_rect.mRight = media_plugin->getWidth(); dirty_rect.mTop = media_plugin->getHeight(); } else { mNeedsUpdate = media_plugin->getDirty(&dirty_rect); } if ( mNeedsUpdate ) { mNeedsUpdate = false; mWebBrowserCtrl->setForceUpdate(false); // 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, getWidth()) - x_pos; S32 height = llmin(dirty_rect.mTop, getHeight()) - y_pos; if(width > 0 && height > 0) { U8* data = media_plugin->getBitsData(); // Offset the pixels pointer to match x_pos and y_pos data += ( x_pos * media_plugin->getTextureDepth() * media_plugin->getBitsWidth() ); data += ( y_pos * media_plugin->getTextureDepth() ); setSubImage( data, media_plugin->getBitsWidth(), media_plugin->getBitsHeight(), x_pos, y_pos, width, height, TRUE); // force a fast update (i.e. don't call analyzeAlpha, etc.) } media_plugin->resetDirty(); return TRUE; }; }; return FALSE; }
void Texture2D::setImage(Image const & image, int level) const { setSubImage(Point2i(), image, level); }