/* [maintenence functions] */ void LocalBitmap::updateSelf() { if ( this->linkstatus == LINK_ON || this->linkstatus == LINK_UPDATING ) { /* making sure file still exists */ if ( !gDirUtilp->fileExists(this->filename) ) { this->linkstatus = LINK_BROKEN; return; } /* exists, let's check if it's lastmod has changed */ llstat temp_stat; LLFile::stat(this->filename, &temp_stat); std::time_t temp_time = temp_stat.st_mtime; LLSD new_last_modified = asctime( localtime(&temp_time) ); if ( this->last_modified.asString() == new_last_modified.asString() ) { return; } /* here we update the image */ LLImageRaw* new_imgraw = new LLImageRaw(); if ( !decodeSelf(new_imgraw) ) { this->linkstatus = LINK_UPDATING; return; } else { this->linkstatus = LINK_ON; } LLViewerFetchedTexture* image = gTextureList.findImage(this->id); if (!image->forSculpt()) { image->createGLTexture( LOCAL_DISCARD_LEVEL, new_imgraw ); } else { image->setCachedRawImage(-1,new_imgraw); } /* finalizing by updating lastmod to current */ this->last_modified = new_last_modified; /* setting unit property to reflect that it has been changed */ switch (this->bitmap_type) { case TYPE_TEXTURE: { break; } case TYPE_SCULPT: { /* sets a bool to run through all visible sculpts in one go, and update the ones necessary. */ this->sculpt_dirty = true; this->volume_dirty = true; gLocalBrowser->setSculptUpdated( true ); break; } case TYPE_LAYER: { /* sets a bool to rebake layers after the iteration is done with */ gLocalBrowser->setLayerUpdated( true ); break; } default: { break; } } } }
LocalBitmap::LocalBitmap(std::string fullpath) { valid = false; if ( gDirUtilp->fileExists(fullpath) ) { /* taking care of basic properties */ id.generate(); filename = fullpath; keep_updating = gSavedSettings.getBOOL("LocalBitmapUpdate"); linkstatus = keep_updating ? LINK_ON : LINK_OFF; shortname = gDirUtilp->getBaseFileName(filename, true); bitmap_type = TYPE_TEXTURE; sculpt_dirty = false; volume_dirty = false; valid = false; /* taking care of extension type now to avoid switch madness */ std::string temp_exten = gDirUtilp->getExtension(filename); if (temp_exten == "bmp") extension = IMG_EXTEN_BMP; else if (temp_exten == "tga") extension = IMG_EXTEN_TGA; else if (temp_exten == "jpg" || temp_exten == "jpeg") extension = IMG_EXTEN_JPG; else if (temp_exten == "png") extension = IMG_EXTEN_PNG; else return; // no valid extension. /* getting file's last modified */ llstat temp_stat; LLFile::stat(filename, &temp_stat); std::time_t time = temp_stat.st_mtime; last_modified = asctime( localtime(&time) ); /* checking if the bitmap is valid && decoding if it is */ LLPointer<LLImageRaw> raw_image = new LLImageRaw; if (decodeSelf(raw_image)) { /* creating a shell LLViewerTexture and fusing raw image into it */ LLViewerFetchedTexture* viewer_image = new LLViewerFetchedTexture( "file://"+filename, id, LOCAL_USE_MIPMAPS ); viewer_image->createGLTexture( LOCAL_DISCARD_LEVEL, raw_image ); viewer_image->setCachedRawImage(-1,raw_image); /* making damn sure gTextureList will not delete it prematurely */ viewer_image->ref(); /* finalizing by adding LLViewerTexture instance into gTextureList */ gTextureList.addImage(viewer_image); /* filename is valid, bitmap is decoded and valid, i can haz liftoff! */ valid = true; } } }
/* [maintenence functions] */ void LLLocalBitmap::updateSelf() { if ( this->mLinkStatus == LS_ON || this->mLinkStatus == LS_UPDATING ) { /* making sure file still exists */ if ( !gDirUtilp->fileExists(this->mFilename) ) { this->mLinkStatus = LS_BROKEN; LLFloaterLocalBitmapBrowser::updateRightSide(); return; } /* exists, let's check if it's lastmod has changed */ const std::time_t temp_time = boost::filesystem::last_write_time( boost::filesystem::path( this->mFilename ) ); LLSD new_last_modified = asctime( localtime(&temp_time) ); if ( this->mLastModified.asString() == new_last_modified.asString() ) { return; } /* here we update the image */ LLImageRaw* new_imgraw = new LLImageRaw(); if ( !decodeSelf(new_imgraw) ) { this->mLinkStatus = LS_UPDATING; return; } else { this->mLinkStatus = LS_ON; } LLViewerFetchedTexture* image = gTextureList.findImage(this->mId); // here was a check if isForSculptOnly, but it appears the function is broken. image->createGLTexture( LOCAL_DISCARD_LEVEL, new_imgraw ); image->setCachedRawImage( LOCAL_DISCARD_LEVEL, new_imgraw ); /* finalizing by updating lastmod to current */ this->mLastModified = new_last_modified; /* setting unit property to reflect that it has been changed */ switch (this->mBitmapType) { case BT_TEXTURE: { break; } case BT_SCULPT: { /* sets a bool to run through all visible sculpts in one go, and update the ones necessary. */ this->mSculptDirty = true; this->mVolumeDirty = true; gLocalBrowser->setSculptUpdated( true ); break; } case BT_LAYER: { /* sets a bool to rebake layers after the iteration is done with */ gLocalBrowser->setLayerUpdated( true ); break; } default: { break; } } } }