void ShaderInstance::compute_run_lazily (const ShaderGroup &group) { if (shadingsys().m_lazylayers) { // lazylayers option turned on: unconditionally run shaders with no // outgoing connections ("root" nodes, including the last in the // group) or shaders that alter global variables (unless // 'lazyglobals' is turned on). if (shadingsys().m_lazyglobals) { if (group[group.nlayers()-1] == this) run_lazily (false); // force run of last group else run_lazily ((outgoing_connections() && ! renderer_outputs()) || empty_instance() || merged_unused()); } else run_lazily (outgoing_connections() && ! writes_globals() && ! renderer_outputs()); #if 0 // Suggested warning below... but are there use cases where people // want these to run (because they will extract the results they // want from output params)? if (! outgoing_connections() && ! empty_instance() && ! writes_globals() && ! renderer_outputs()) shadingsys().warning ("Layer \"%s\" (shader %s) will run even though it appears to have no used results", layername(), shadername()); #endif } else { // lazylayers option turned off: never run lazily run_lazily (false); } }
void ShaderInstance::copy_code_from_master (ShaderGroup &group) { ASSERT (m_instops.empty() && m_instargs.empty()); // reserve with enough room for a few insertions m_instops.reserve (master()->m_ops.size()+10); m_instargs.reserve (master()->m_args.size()+10); m_instops = master()->m_ops; m_instargs = master()->m_args; // Copy the symbols from the master ASSERT (m_instsymbols.size() == 0 && "should not have copied m_instsymbols yet"); m_instsymbols = m_master->m_symbols; // Copy the instance override data // Also set the renderer_output flags where needed. ASSERT (m_instoverrides.size() == (size_t)std::max(0,lastparam())); ASSERT (m_instsymbols.size() >= (size_t)std::max(0,lastparam())); if (m_instoverrides.size()) { for (size_t i = 0, e = lastparam(); i < e; ++i) { Symbol *si = &m_instsymbols[i]; if (m_instoverrides[i].valuesource() == Symbol::DefaultVal) { // Fix the length of any default-value variable length array // parameters. if (si->typespec().is_unsized_array()) si->arraylen (si->initializers()); } else { if (m_instoverrides[i].arraylen()) si->arraylen (m_instoverrides[i].arraylen()); si->valuesource (m_instoverrides[i].valuesource()); si->connected_down (m_instoverrides[i].connected_down()); si->lockgeom (m_instoverrides[i].lockgeom()); si->data (param_storage(i)); } if (shadingsys().is_renderer_output (layername(), si->name(), &group)) { si->renderer_output (true); renderer_outputs (true); } } } evaluate_writes_globals_and_userdata_params (); off_t symmem = vectorbytes(m_instsymbols) - vectorbytes(m_instoverrides); SymOverrideInfoVec().swap (m_instoverrides); // free it // adjust stats { spin_lock lock (shadingsys().m_stat_mutex); shadingsys().m_stat_mem_inst_syms += symmem; shadingsys().m_stat_mem_inst += symmem; shadingsys().m_stat_memory += symmem; } }
void QgsVectorLayerSaveAsDialog::accept() { if ( QFile::exists( filename() ) ) { QgsVectorFileWriter::EditionCapabilities caps = QgsVectorFileWriter::editionCapabilities( filename() ); bool layerExists = QgsVectorFileWriter::targetLayerExists( filename(), layername() ); if ( layerExists ) { if ( !( caps & QgsVectorFileWriter::CanAppendToExistingLayer ) && ( caps & QgsVectorFileWriter::CanDeleteLayer ) && ( caps & QgsVectorFileWriter::CanAddNewLayer ) ) { QMessageBox msgBox; msgBox.setIcon( QMessageBox::Question ); msgBox.setWindowTitle( tr( "The layer already exists" ) ); msgBox.setText( tr( "Do you want to overwrite the whole file or overwrite the layer?" ) ); QPushButton *overwriteFileButton = msgBox.addButton( tr( "Overwrite file" ), QMessageBox::ActionRole ); QPushButton *overwriteLayerButton = msgBox.addButton( tr( "Overwrite layer" ), QMessageBox::ActionRole ); msgBox.setStandardButtons( QMessageBox::Cancel ); msgBox.setDefaultButton( QMessageBox::Cancel ); int ret = msgBox.exec(); if ( ret == QMessageBox::Cancel ) return; if ( msgBox.clickedButton() == overwriteFileButton ) mActionOnExistingFile = QgsVectorFileWriter::CreateOrOverwriteFile; else if ( msgBox.clickedButton() == overwriteLayerButton ) mActionOnExistingFile = QgsVectorFileWriter::CreateOrOverwriteLayer; } else if ( !( caps & QgsVectorFileWriter::CanAppendToExistingLayer ) ) { if ( QMessageBox::question( this, tr( "The file already exists" ), tr( "Do you want to overwrite the existing file?" ) ) == QMessageBox::NoButton ) { return; } mActionOnExistingFile = QgsVectorFileWriter::CreateOrOverwriteFile; } else if (( caps & QgsVectorFileWriter::CanDeleteLayer ) && ( caps & QgsVectorFileWriter::CanAddNewLayer ) ) { QMessageBox msgBox; msgBox.setIcon( QMessageBox::Question ); msgBox.setWindowTitle( tr( "The layer already exists" ) ); msgBox.setText( tr( "Do you want to overwrite the whole file, overwrite the layer or append features to the layer?" ) ); QPushButton *overwriteFileButton = msgBox.addButton( tr( "Overwrite file" ), QMessageBox::ActionRole ); QPushButton *overwriteLayerButton = msgBox.addButton( tr( "Overwrite layer" ), QMessageBox::ActionRole ); QPushButton *appendToLayerButton = msgBox.addButton( tr( "Append to layer" ), QMessageBox::ActionRole ); msgBox.setStandardButtons( QMessageBox::Cancel ); msgBox.setDefaultButton( QMessageBox::Cancel ); int ret = msgBox.exec(); if ( ret == QMessageBox::Cancel ) return; if ( msgBox.clickedButton() == overwriteFileButton ) mActionOnExistingFile = QgsVectorFileWriter::CreateOrOverwriteFile; else if ( msgBox.clickedButton() == overwriteLayerButton ) mActionOnExistingFile = QgsVectorFileWriter::CreateOrOverwriteLayer; else if ( msgBox.clickedButton() == appendToLayerButton ) mActionOnExistingFile = QgsVectorFileWriter::AppendToLayerNoNewFields; } else { QMessageBox msgBox; msgBox.setIcon( QMessageBox::Question ); msgBox.setWindowTitle( tr( "The layer already exists" ) ); msgBox.setText( tr( "Do you want to overwrite the whole file or append features to the layer?" ) ); QPushButton *overwriteFileButton = msgBox.addButton( tr( "Overwrite file" ), QMessageBox::ActionRole ); QPushButton *appendToLayerButton = msgBox.addButton( tr( "Append to layer" ), QMessageBox::ActionRole ); msgBox.setStandardButtons( QMessageBox::Cancel ); msgBox.setDefaultButton( QMessageBox::Cancel ); int ret = msgBox.exec(); if ( ret == QMessageBox::Cancel ) return; if ( msgBox.clickedButton() == overwriteFileButton ) mActionOnExistingFile = QgsVectorFileWriter::CreateOrOverwriteFile; else if ( msgBox.clickedButton() == appendToLayerButton ) mActionOnExistingFile = QgsVectorFileWriter::AppendToLayerNoNewFields; } if ( mActionOnExistingFile == QgsVectorFileWriter::AppendToLayerNoNewFields ) { if ( QgsVectorFileWriter::areThereNewFieldsToCreate( filename(), layername(), mLayer, selectedAttributes() ) ) { if ( QMessageBox::question( this, tr( "The existing layer has different fields" ), tr( "Do you want to add the missing fields to the layer?" ) ) == QMessageBox::Yes ) { mActionOnExistingFile = QgsVectorFileWriter::AppendToLayerAddFields; } } } } else { if (( caps & QgsVectorFileWriter::CanAddNewLayer ) ) { mActionOnExistingFile = QgsVectorFileWriter::CreateOrOverwriteLayer; } else { if ( QMessageBox::question( this, tr( "The file already exists" ), tr( "Do you want to overwrite the existing file?" ) ) == QMessageBox::NoButton ) { return; } mActionOnExistingFile = QgsVectorFileWriter::CreateOrOverwriteFile; } } } QSettings settings; settings.setValue( "/UI/lastVectorFileFilterDir", QFileInfo( filename() ).absolutePath() ); settings.setValue( "/UI/lastVectorFormat", format() ); settings.setValue( "/UI/encoding", encoding() ); QDialog::accept(); }