// Reimplemented void QmvItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ) { QListView *listview = listView(); QColorGroup g( cg ); g.setColor( QColorGroup::Base, backgroundColor() ); g.setColor( QColorGroup::Foreground, Qt::black ); g.setColor( QColorGroup::Text, Qt::black ); int indent = 0; if ( column == 0 ) { indent = 20 + (shuttletupleattribute ? 20 : 0 ); p->fillRect( 0, 0, width, height(), backgroundColor() ); p->save(); p->translate( indent, 0 ); } if ( isChanged() && column == 0 ) { p->save(); QFont f = p->font(); f.setBold( TRUE ); p->setFont( f ); } if ( !hasCustomContents() || column != 1 ) { QListViewItem::paintCell( p, g, column, width - indent, alignment ); } else { p->fillRect( 0, 0, width, height(), backgroundColor() ); drawCustomContents( p, QRect( 0, 0, width, height() ) ); } if ( isChanged() && column == 0 ) p->restore(); if ( column == 0 ) p->restore(); // Draw +/- open/close control icon on tuple items if ( !shuttletupleattribute && column == 0 ) { p->save(); p->setPen( cg.foreground() ); p->setBrush( cg.base() ); p->drawRect( 5, height() / 2 - 4, 9, 9 ); p->drawLine( 7, height() / 2, 11, height() / 2 ); if ( !isOpen() ) p->drawLine( 9, height() / 2 - 2, 9, height() / 2 + 2 ); p->restore(); } p->save(); p->setPen( QPen( cg.dark(), 1 ) ); p->drawLine( 0, height() - 1, width, height() - 1 ); p->drawLine( width - 1, 0, width - 1, height() ); p->restore(); if ( listview->currentItem() == this && column == 0 && !listview->hasFocus() && !listview->viewport()->hasFocus() ) paintFocus( p, cg, QRect( 0, 0, width, height() ) ); }
CachedUnit lookupUnitNonRepoAuth(StringData* requestedPath, const struct stat* statInfo, OptLog& ent, const Native::FuncTable& nativeFuncs, FileLoadFlags& flags) { auto const& options = RepoOptions::forFile(requestedPath->data()); if (!g_context.isNull() && strncmp(requestedPath->data(), "/:", 2)) { g_context->onLoadWithOptions(requestedPath->data(), options); } // Steady state, its probably already in the cache. Try that first { rqtrace::EventGuard trace{"READ_UNIT"}; NonRepoUnitCache::const_accessor acc; if (s_nonRepoUnitCache.find(acc, requestedPath)) { auto const cachedUnit = acc->second.cachedUnit.copy(); if (!isChanged(cachedUnit, statInfo, options)) { auto const cu = cachedUnit->cu; if (!cu.unit || !RuntimeOption::CheckSymLink || !strcmp(StatCache::realpath(requestedPath->data()).c_str(), cu.unit->filepath()->data())) { if (ent) ent->setStr("type", "cache_hit_readlock"); flags = FileLoadFlags::kHitMem; return cu; } } } } return loadUnitNonRepoAuth(requestedPath, statInfo, ent, nativeFuncs, options, flags); }
VOID ProcessFileSelection(HWND hwnd, PATTMAN pam) { int idx; idx = DlgLboxQuerySelectedItem(hwnd, LB_FILE); // se il primo file selezionato non Š uguale al primo precedente if (idx != pam->fsp.psSel[1]) { // aggiorna dati file // se prima esecuzione o attrib immutati o salvati: if (pam->fsp.psSel[0] < 0 || !isChanged(hwnd, pam)) { dprintf("Lettura attributi file"); UpdateSelFilesArray(hwnd, pam); // aggiorna array file selezionati SetWinTitle(hwnd, pam); // aggiorna titolo finestra if (GetAttr(hwnd, &pam->fsp) == 0 && pam->pro.imp.autoimp) { pam->sMenuFrom = LB_FILE; // indica che viene da selezione file ImportFileData(hwnd, pam); } // end if } else { // Š stato premuto cancel x cui ripristina file preced selez dprintf("Ripristino precedente selezione (%d files)\n", pam->fsp.psSel[0]); DeselectAllFiles(hwnd, pam); // cancella nuova selezione for (idx = 1; idx <= pam->fsp.psSel[0]; idx++) MyDlgLboxSelectItem(hwnd, LB_FILE, pam->fsp.psSel[idx]); } /* endif */ } else { UpdateSelFilesArray(hwnd, pam); // aggiorna array file selezionati SetWinTitle(hwnd, pam); // aggiorna titolo finestra } // end if }
Theme::~Theme() { if (!isChanged()) { return; } QSettings settings(filePath(m_name), QSettings::IniFormat); // Store background settings settings.setValue("Background/Type", m_background_type); settings.setValue("Background/Color", m_background_color.name()); if (!m_background_path.isEmpty()) { settings.setValue("Background/Image", m_background_path); } settings.setValue("Background/ImageFile", m_background_image); // Store foreground settings settings.setValue("Foreground/Color", m_foreground_color.name()); settings.setValue("Foreground/Opacity", m_foreground_opacity); settings.setValue("Foreground/Width", m_foreground_width); settings.setValue("Foreground/Rounding", m_foreground_rounding); settings.setValue("Foreground/Margin", m_foreground_margin); settings.setValue("Foreground/Padding", m_foreground_padding); settings.setValue("Foreground/Position", m_foreground_position); // Store text settings settings.setValue("Text/Color", m_text_color.name()); settings.setValue("Text/Font", m_text_font.toString()); settings.setValue("Text/Misspelled", m_misspelled_color.name()); }
void TranslationLine::textChangedSlot() { fixSize(); if(isChanged())setStyleSheet("color: "+baseValues.appTheme.black.name()); else setStyleSheet("color: "+baseValues.appTheme.red.name()); emit lineTextChanged(); }
void OverlayCategory::update() { if ( getOverlay().isVisible() ) { OverlayRendererSPtr renderer = getOverlay().getEngine()->getOverlayCache().getRenderer(); if ( renderer ) { if ( isPositionChanged() || renderer->isSizeChanged() ) { doUpdatePosition(); } if ( isSizeChanged() || renderer->isSizeChanged() ) { doUpdateSize(); } if ( isChanged() || isSizeChanged() || renderer->isSizeChanged() ) { doUpdate(); doUpdateBuffer( renderer->getSize() ); } m_positionChanged = false; m_sizeChanged = false; } } }
VOID ProcessDriveSelection(HWND hwnd, MPARAM mp1, PATTMAN pam) { SHORT currIdx; // indice drive correntemente selezionato ULONG ulRes; currIdx = DlgLboxQuerySelectedItem(hwnd, LB_DRIVE); // controlla se Š selezionato dall'utente o come effetto collaterale if (pam->LMsel) return; // di un altro messaggio if (currIdx == pam->fsp.sPrvDrv) return; // non Š stato selez nuovo drive // se attributo non Š cambiato, modo readonly, o si Š prem Save o Discard if (!isChanged(hwnd, pam)) { //nel dialogo "Save.." DlgLboxQueryItemText(hwnd, LB_DRIVE, currIdx, pam->fsp.pszPath, 256); // controlla che il drive selezionato sia disponibile if (SetDisk(hwnd, pam->fsp.pszPath[1], &pam->fsp.hpfs)) {//Cancel : rimane in curr dir QueryCurrentPath(pam->fsp.pszPath, pam->fsp.pszFile); MyDlgLboxSelectItem(hwnd, LB_DRIVE, pam->fsp.sPrvDrv); } else { // drive disponibile pam->fsp.psSel[1] = -2; // forza aggiornamento dati QueryCurrentPath(pam->fsp.pszPath, pam->fsp.pszFile); FillDirList(hwnd, pam); pam->fsp.sPrvDrv = currIdx; } // endif } else { // se si Š premuto Cancel riseleziona il drive precedente MyDlgLboxSelectItem(hwnd, LB_DRIVE, pam->fsp.sPrvDrv); } /* endif */ }
void RandomPolygonMenu::update( float dt ){ world->update( dt ); Menu::update( dt ); if( isChanged() ){ generateTable(); } }
void LiquidCrystal::print(const char* str) { int len = strlen(str); for (int n = 0; n < len; n++) writeChar(str[n]); if (isChanged()) renderScreen(); } // print()
void GVPreferencesGeneral::OnChangeTurnPath(wxCommandEvent& event) { if(m_turnpath != event.GetString()) addChange("game"); else delChange("game"); if(isChanged()) m_pParent->EnableApply(true); else m_pParent->EnableApply(false); }
void QmvItem::updateResetButtonState() { if ( !resetButton ) return; if ( shuttletupleAttribute() ) resetButton->setEnabled( isChanged() ); // else // resetButton->setEnabled( ); }
void GVPreferencesGeneral::OnChangeGameDirectory(wxCommandEvent& event) { if(m_gamepath != event.GetString()) addChange("gamedirectory"); else delChange("gamedirectory"); if(isChanged()) m_pParent->EnableApply(true); else m_pParent->EnableApply(false); }
void GVPreferencesGeneral::OnChangeTextEditorPath(wxCommandEvent& event) { if(m_texteditorpath != event.GetString()) addChange("texteditor"); else delChange("texteditor"); if(isChanged()) m_pParent->EnableApply(true); else m_pParent->EnableApply(false); }
CachedUnit lookupUnitNonRepoAuth(StringData* requestedPath, const struct stat& statInfo) { if (strstr(requestedPath->data(), "://") != nullptr) { // URL-based units are not currently cached in memory, but the Repo still // caches them on disk. return createUnitFromUrl(requestedPath); } // The string we're using as a key must be static, because we're using it as // a key in the cache (across requests). auto const path = makeStaticString( // XXX: it seems weird we have to do this even though we already ran // resolveVmInclude. (requestedPath->data()[0] == '/' ? requestedPath : String(SourceRootInfo::GetCurrentSourceRoot()) + StrNR(requestedPath) ).get() ); NonRepoUnitCache::accessor acc; if (!s_nonRepoUnitCache.insert(acc, path)) { if (!isChanged(acc->second, statInfo)) { return acc->second.cachedUnit; } } /* * NB: the new-unit creation path is here, and is done while holding the tbb * lock on s_nonRepoUnitCache. This was originally done deliberately to * avoid wasting time in the compiler (during server startup, many requests * hit the same code initial paths that are shared, and would all be * compiling the same files). It's not 100% clear if this is the best way to * handle that idea, though (tbb locks spin aggressively and are expected to * be low contention). */ /* * Don't cache if createNewUnit returns an empty CachedUnit---we'll need to * try again anyway if someone tries to load this path, since it might exist * later. * * If there was a unit for this path already, we need to put it on the * Treadmill for eventual reclaimation. We can't delete it immediately * because other requests may still be using it. */ auto const cu = createUnitFromFile(path); if (auto const oldUnit = acc->second.cachedUnit.unit) { Treadmill::enqueue([oldUnit] { reclaimUnit(oldUnit); }); } acc->second.cachedUnit = cu; acc->second.mtime = statInfo.st_mtim; acc->second.ino = statInfo.st_ino; acc->second.devId = statInfo.st_dev; return cu; }
void SharpnessFilter::applyFilter(){ if(isChanged() && !noneType){ /*if(noneType){ processedImg = tempOriginalImg.clone(); }*/ if(!tempImage.empty()){ cv::addWeighted(originalImg,1.7,tempImage,-0.7,0,processedImg); } setChanged(false); } }
void LiquidCrystal::clear() { memset(screenBuffer,0x20,bufferSize); memset(lastScreen,0x20,screenSize); x = 0; y = 0; if (isChanged() || firstClear) renderScreen(); firstClear = false; } // clear()
void LiquidCrystal::scrollDisplayRight() { for (int n = bufferSize; n > 0; --n) { screenBuffer[n] = screenBuffer[n - 1]; } for (int row = 0; row < h; row++) { screenBuffer[(row * 3 * w) + (3 * w) - 1] = ' '; } if (isChanged()) renderScreen(); } // scrollDisplayLeft()
void LiquidCrystal::scrollDisplayLeft() { for (int n = 1; n < bufferSize; n++) { screenBuffer[n - 1] = screenBuffer[n]; } for (int row = 0; row < h; row++) { screenBuffer[row * 3 * w] = ' '; } if (isChanged()) renderScreen(); } // scrollDisplayLeft()
void runReplaceDashWithUnderscore(void) { std::string stringToValidate; std::cout << "Welcome to the dash replacement program." << std::endl; std::cout << "Please input the string to be evaluated: " << std::endl; std::getline(std::cin, stringToValidate); if(isChanged(stringToValidate)) std::cout << "The string has been changed. Dashes have been replaced:" << std::endl << stringToValidate << std::endl; else std::cout << "The string has no dashes. It has not been changed." << std::endl; return; }
glm::mat4 Model::getModelMatrix() { if(isChanged()) { setChanged(false); glm::vec3 pos = getPosition(); glm::quat orientation = getOrientation(); //scale-rotate-translate glm::mat4 rot = glm::mat4_cast(orientation); glm::mat4 trans = glm::translate(glm::mat4(1.0),pos); glm::mat4 scale = glm::scale(glm::mat4(1.0),this->getScale()); setCachedModelMatrix(trans*rot*scale*glm::translate(glm::mat4(1.0),-getBoundingBox()->getCenter())); } return getCachedModelMatrix(); }
Theme::~Theme() { if (!isChanged()) { return; } QSettings settings(filePath(m_name), QSettings::IniFormat); // Store background settings settings.setValue("Background/Type", m_background_type); settings.setValue("Background/Color", m_background_color.name()); if (!m_background_path.isEmpty()) { settings.setValue("Background/Image", m_background_path); } settings.setValue("Background/ImageFile", m_background_image); // Store foreground settings settings.setValue("Foreground/Color", m_foreground_color.name()); settings.setValue("Foreground/Opacity", m_foreground_opacity); settings.setValue("Foreground/Width", m_foreground_width); settings.setValue("Foreground/Rounding", m_foreground_rounding); settings.setValue("Foreground/Margin", m_foreground_margin); settings.setValue("Foreground/Padding", m_foreground_padding); settings.setValue("Foreground/Position", m_foreground_position); // Store text settings settings.setValue("Text/Color", m_text_color.name()); settings.setValue("Text/Font", m_text_font.toString()); settings.setValue("Text/Misspelled", m_misspelled_color.name()); QHashIterator<QString,QTextBlockFormat> it(m_block_default_format); while (it.hasNext()) { it.next(); settings.setValue(QString("Styles/")+it.key()+QString("/FontWeight"),it.value().intProperty(QTextFormat::FontWeight)); settings.setValue(QString("Styles/")+it.key()+QString("/FontItalic"),it.value().boolProperty(QTextFormat::FontItalic)); settings.setValue(QString("Styles/")+it.key()+QString("/FontSizeAdjustment"),it.value().intProperty(QTextFormat::FontSizeAdjustment)); settings.setValue(QString("Styles/")+it.key()+QString("/BlockLeftMargin"),it.value().doubleProperty(QTextFormat::BlockLeftMargin)); settings.setValue(QString("Styles/")+it.key()+QString("/BlockRightMargin"),it.value().doubleProperty(QTextFormat::BlockRightMargin)); settings.setValue(QString("Styles/")+it.key()+QString("/BlockTopMargin"),it.value().doubleProperty(QTextFormat::BlockTopMargin)); settings.setValue(QString("Styles/")+it.key()+QString("/BlockBottomMargin"),it.value().doubleProperty(QTextFormat::BlockBottomMargin)); settings.setValue(QString("Styles/")+it.key()+QString("/BlockAlignment"),it.value().intProperty(QTextFormat::BlockAlignment)); settings.setValue(QString("Styles/")+it.key()+QString("/BlockTrailingHorizontalRulerWidth"),it.value().lengthProperty(QTextFormat::BlockTrailingHorizontalRulerWidth).rawValue()); settings.setValue(QString("Styles/")+it.key()+QString("/BlockNonBreakableLines"),it.value().boolProperty(QTextFormat::BlockNonBreakableLines)); } }
Preferences::~Preferences() { if (!isChanged()) { return; } QSettings settings; settings.setValue("Goal/Type", m_goal_type); settings.setValue("Goal/Minutes", m_goal_minutes); settings.setValue("Goal/Words", m_goal_words); settings.setValue("Stats/ShowCharacters", m_show_characters); settings.setValue("Stats/ShowPages", m_show_pages); settings.setValue("Stats/ShowParagraphs", m_show_paragraphs); settings.setValue("Stats/ShowWords", m_show_words); settings.setValue("Stats/PageSizeType", m_page_type); settings.setValue("Stats/CharactersPerPage", m_page_characters); settings.setValue("Stats/ParagraphsPerPage", m_page_paragraphs); settings.setValue("Stats/WordsPerPage", m_page_words); settings.setValue("Stats/AccurateWordcount", m_accurate_wordcount); settings.setValue("Edit/AlwaysCenter", m_always_center); settings.setValue("Edit/BlockCursor", m_block_cursor); settings.setValue("Edit/RichText", m_rich_text); settings.setValue("Edit/SmoothFonts", m_smooth_fonts); settings.setValue("Edit/SmartQuotes", m_smart_quotes); settings.setValue("Edit/SmartDoubleQuotes", m_double_quotes); settings.setValue("Edit/SmartSingleQuotes", m_single_quotes); settings.setValue("Edit/TypewriterSounds", m_typewriter_sounds); settings.setValue("Save/Auto", m_auto_save); settings.setValue("Save/RememberPositions", m_save_positions); settings.setValue("Toolbar/Style", m_toolbar_style); settings.setValue("Toolbar/Actions", m_toolbar_actions); settings.setValue("Spelling/HighlightMisspelled", m_highlight_misspelled); settings.setValue("Spelling/IgnoreNumbers", m_ignore_numbers); settings.setValue("Spelling/IgnoreUppercase", m_ignore_uppercase); settings.setValue("Spelling/Language", m_language); }
void FaceDetector::applyFilter() { static int a = 0; //frameCount++; dotPatternFilter->setLogText(logTxt); //cv::flip(grayImgMat,grayImgMat,1); if(isChanged()){ faces.clear(); tempfaces.clear(); if(medianBlurSize%2 != 1){ appendLog(QString::number(medianBlurSize)); medianBlurSize++; } cv::medianBlur(grayImgMat,grayImgMat,medianBlurSize); if(!frontalFaceCascade.empty()){ frontalFaceCascade.detectMultiScale(grayImgMat,faces,1.1,rectThreshold,0,cv::Size(10,10)); } if(!profileFaceCascade.empty()){ profileFaceCascade.detectMultiScale(grayImgMat,tempfaces,1.1,rectThreshold,0,cv::Size(10,10)); for(int i=0; i<tempfaces.size();++i){ faces.push_back(tempfaces[i]); } } originalImg.copyTo(processedImg); //cv::flip(processedImg,processedImg,1); for(int i=0; i<faces.size(); ++i){ cv::rectangle(processedImg,faces[i],cv::Scalar(0,0,0),3,8,0); cv::Mat ff(processedImg,faces[i]); cv::Ptr<cv::FeatureDetector> d = cv::AKAZE::create(); std::vector<cv::KeyPoint> keypoints; d->detect(ff,keypoints); cv::drawKeypoints(ff,keypoints,ff); if(currentFilter!=NULL){ cv::Mat temp(processedImg,faces[i]); currentFilter->setImage(temp); currentFilter->applyFilter(); temp = currentFilter->getImage(); temp.copyTo(processedImg(faces[i])); } } setChanged(false); } }
QVariant EditableResultsetTableModel::data(const QModelIndex &ix, int role) const { if(!ix.isValid()){ return QVariant(); } if(ix.row()<insertedRows.size()){ if((role==Qt::DisplayRole || role==Qt::EditRole) && ix.column() < columnCount()){ return insertedRows.at(ix.row()).at(ix.column()); }else{ return QVariant(); } } QModelIndex newIndex = insertedRows.size() == 0 ? ix : index(ix.row() - insertedRows.size(), ix.column()); QVariant value = ResultsetTableModel::data(newIndex, role); if(!value.isValid() && !role==Qt::DecorationRole){ return value; } bool isDeleted = deletedRows.contains(newIndex.row()); bool changed = !isDeleted && isChanged(newIndex.row(), newIndex.column()); if(changed){ if(role == Qt::DisplayRole || role == Qt::EditRole){ value = changedData[newIndex.row()][newIndex.column()]; }else if(role == Qt::DecorationRole){ value = IconUtil::getIcon("edit_small"); } } if(role == Qt::FontRole && isDeleted){ QFont f=qApp->font("QTableView"); f.setStrikeOut(true); value = f; } return value; }
Theme::~Theme() { if (!isChanged()) { return; } QSettings settings(filePath(m_name), QSettings::IniFormat); // Store background settings settings.setValue("Background/Type", m_background_type); settings.setValue("Background/Color", m_background_color.name()); if (!m_background_path.isEmpty()) { settings.setValue("Background/Image", m_background_path); } settings.setValue("Background/ImageFile", m_background_image); // Store foreground settings settings.setValue("Foreground/Color", m_foreground_color.name()); settings.setValue("Foreground/Opacity", m_foreground_opacity); settings.setValue("Foreground/Width", m_foreground_width); settings.setValue("Foreground/Rounding", m_foreground_rounding); settings.setValue("Foreground/Margin", m_foreground_margin); settings.setValue("Foreground/Padding", m_foreground_padding); settings.setValue("Foreground/Position", m_foreground_position); // Store text settings settings.setValue("Text/Color", m_text_color.name()); settings.setValue("Text/Font", m_text_font.toString()); settings.setValue("Text/Misspelled", m_misspelled_color.name()); // Store spacings settings.setValue("Spacings/IndentFirstLine", m_indent_first_line); settings.setValue("Spacings/LineSpacing", m_line_spacing); settings.setValue("Spacings/ParagraphAbove", m_paragraph_spacing_above); settings.setValue("Spacings/ParagraphBelow", m_paragraph_spacing_below); }
void LiquidCrystal::write(char chr) { writeChar(chr); if (isChanged()) renderScreen(); } // write()
//-------------------------------------------------------------- void apparelMood_porcupinopathy::apply() { apparelMod_selfopathy* pModSelfopathy = GLOBALS->mp_modSelfopathy;//(apparelMod_selfopathy*) GLOBALS->getModManager()->getMod(""); m_model.mesh = m_meshInput; if (pModSelfopathy) { m_meshSpikes.clear(); apparelModel& model = pModSelfopathy->m_model; vector<ofIndexType>& indices = model.getMeshRef().getIndices(); ofVec3f A,B,C,M,n; for (int i=0;i<indices.size(); i=i+3) { ofIndexType indexA = indices[i]; ofIndexType indexB = indices[i+1]; ofIndexType indexC = indices[i+2]; A = model.getMeshRef().getVertex( indexA ); B = model.getMeshRef().getVertex( indexB ); C = model.getMeshRef().getVertex( indexC ); M = (A+B+C)/3.0f; n = (B-A).cross(C-A).normalize(); M = M + 5*n; int nbIndices = m_meshSpikes.getNumVertices(); m_meshSpikes.addVertex( A ); m_meshSpikes.addVertex( B ); m_meshSpikes.addVertex( C ); m_meshSpikes.addVertex( M ); m_meshSpikes.addIndex( nbIndices ); m_meshSpikes.addIndex( nbIndices+1 ); m_meshSpikes.addIndex( nbIndices+2 ); m_meshSpikes.addIndex( nbIndices ); m_meshSpikes.addIndex( nbIndices+1 ); m_meshSpikes.addIndex( nbIndices+3 ); m_meshSpikes.addIndex( nbIndices+1 ); m_meshSpikes.addIndex( nbIndices+2 ); m_meshSpikes.addIndex( nbIndices+3 ); m_meshSpikes.addIndex( nbIndices+2 ); m_meshSpikes.addIndex( nbIndices+0 ); m_meshSpikes.addIndex( nbIndices+3 ); } m_model.mesh.append( m_meshSpikes ); } if (isChanged()) { // m_model.mesh = m_meshInput; } }
CachedUnit loadUnitNonRepoAuth(StringData* requestedPath, const struct stat* statInfo, OptLog& ent, const Native::FuncTable& nativeFuncs, const RepoOptions& options, FileLoadFlags& flags) { LogTimer loadTime("load_ms", ent); if (strstr(requestedPath->data(), "://") != nullptr) { // URL-based units are not currently cached in memory, but the Repo still // caches them on disk. return createUnitFromUrl(requestedPath, nativeFuncs, flags); } rqtrace::EventGuard trace{"WRITE_UNIT"}; // The string we're using as a key must be static, because we're using it as // a key in the cache (across requests). auto const path = makeStaticString( // XXX: it seems weird we have to do this even though we already ran // resolveVmInclude. (FileUtil::isAbsolutePath(requestedPath->toCppString()) ? String{requestedPath} : String(SourceRootInfo::GetCurrentSourceRoot()) + StrNR(requestedPath) ).get() ); auto const rpath = [&] () -> const StringData* { if (RuntimeOption::CheckSymLink) { std::string rp = StatCache::realpath(path->data()); if (rp.size() != 0) { if (rp.size() != path->size() || memcmp(rp.data(), path->data(), rp.size())) { return makeStaticString(rp); } } } return path; }(); Stream::Wrapper* w = nullptr; auto& cache = getNonRepoCache(rpath, w); assertx( !w || &cache != &s_nonRepoUnitCache || !RuntimeOption::EvalUnixServerQuarantineUnits ); // Freeing a unit while holding the tbb lock would cause a rank violation when // recycle-tc is enabled as reclaiming dead functions requires that the code // and metadata locks be acquired. Unit* releaseUnit = nullptr; SCOPE_EXIT { if (releaseUnit) delete releaseUnit; }; auto const updateAndUnlock = [] (auto& cachedUnit, auto p) { auto old = cachedUnit.update_and_unlock(std::move(p)); if (old) { // We don't need to do anything explicitly; the copy_ptr // destructor will take care of it. Treadmill::enqueue([unit_to_delete = std::move(old)] () {}); } }; auto cuptr = [&] { NonRepoUnitCache::const_accessor rpathAcc; cache.insert(rpathAcc, rpath); auto& cachedUnit = rpathAcc->second.cachedUnit; if (auto const tmp = cachedUnit.copy()) { if (!isChanged(tmp, statInfo, options)) { flags = FileLoadFlags::kHitMem; if (ent) ent->setStr("type", "cache_hit_readlock"); return tmp; } } cachedUnit.lock_for_update(); try { if (auto const tmp = cachedUnit.copy()) { if (!isChanged(tmp, statInfo, options)) { cachedUnit.unlock(); flags = FileLoadFlags::kWaited; if (ent) ent->setStr("type", "cache_hit_writelock"); return tmp; } if (ent) ent->setStr("type", "cache_stale"); } else { if (ent) ent->setStr("type", "cache_miss"); } trace.finish(); auto const cu = createUnitFromFile(rpath, &releaseUnit, w, ent, nativeFuncs, options, flags); auto const isICE = cu.unit && cu.unit->isICE(); auto p = copy_ptr<CachedUnitWithFree>(cu, statInfo, isICE, options); // Don't cache the unit if it was created in response to an internal error // in ExternCompiler. Such units represent transient events. if (UNLIKELY(isICE)) { cachedUnit.unlock(); return p; } updateAndUnlock(cachedUnit, p); return p; } catch (...) { cachedUnit.unlock(); throw; } }(); auto const ret = cuptr->cu; if (!ret.unit || !ret.unit->isICE()) { if (path != rpath) { NonRepoUnitCache::const_accessor pathAcc; cache.insert(pathAcc, path); if (pathAcc->second.cachedUnit.get().get() != cuptr) { auto& cachedUnit = pathAcc->second.cachedUnit; cachedUnit.lock_for_update(); updateAndUnlock(cachedUnit, std::move(cuptr)); } } } return ret; }
void ShaderCompiler::makeUpToDate() { auto* iter = PlatformInterface::createFileIterator("shaders", m_editor.getAllocator()); Lumix::Array<Lumix::string> src_list(m_editor.getAllocator()); auto& fs = m_editor.getEngine().getFileSystem(); PlatformInterface::FileInfo info; while (getNextFile(iter, &info)) { char basename[Lumix::MAX_PATH_LENGTH]; Lumix::PathUtils::getBasename(basename, sizeof(basename), info.filename); if (!Lumix::PathUtils::hasExtension(info.filename, "shd")) continue; const char* shd_path = StringBuilder<Lumix::MAX_PATH_LENGTH>( "shaders/", info.filename); auto* file = fs.open(fs.getDiskDevice(), shd_path, Lumix::FS::Mode::OPEN_AND_READ); if (!file) { Lumix::g_log_error.log("shader compiler") << "Could not open " << info.filename; continue; } int len = (int)file->size(); Lumix::Array<char> data(m_editor.getAllocator()); data.resize(len+1); file->read(&data[0], len); data[len] = 0; fs.close(*file); Lumix::ShaderCombinations combinations; Lumix::Shader::getShaderCombinations( getRenderer(), &data[0], &combinations); const char* bin_base_path = StringBuilder<Lumix::MAX_PATH_LENGTH>("shaders/compiled/", basename, "_"); if (isChanged(combinations, bin_base_path, shd_path)) { src_list.emplace(shd_path, m_editor.getAllocator()); } } PlatformInterface::destroyFileIterator(iter); for (int i = 0; i < m_dependencies.size(); ++i) { auto& key = m_dependencies.getKey(i); auto& value = m_dependencies.at(i); for (auto& bin : value) { if (!Lumix::fileExists(bin.c_str()) || Lumix::getLastModified(bin.c_str()) < Lumix::getLastModified(key.c_str())) { char basename[Lumix::MAX_PATH_LENGTH]; Lumix::PathUtils::getBasename(basename, sizeof(basename), bin.c_str()); char tmp[Lumix::MAX_PATH_LENGTH]; getSourceFromBinaryBasename(tmp, sizeof(tmp), basename); Lumix::string src(tmp, m_editor.getAllocator()); src_list.push(src); } } } src_list.removeDuplicates(); for (auto src : src_list) { compile(src.c_str()); } }