CPLErr GDALRasterBlock::Write() { if( !GetDirty() ) return CE_None; if( poBand == NULL ) return CE_Failure; MarkClean(); return poBand->IWriteBlock( nXOff, nYOff, pData ); }
void Shader::BindSubMesh(const std::shared_ptr<Mesh> &mesh, unsigned int index) { auto subMesh = mesh->GetSubMeshAt(index); if (subMesh == nullptr) { FURYW << "SubMesh out of range!"; return; } if (mesh->GetDirty()) mesh->UpdateBuffer(); if (subMesh->GetDirty()) subMesh->UpdateBuffer(); if (m_Dirty || mesh->GetDirty() || subMesh->GetDirty() || subMesh->Indices.GetDirty()) return; BindMeshData(mesh); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, subMesh->Indices.GetID()); }
void CMainWindow::OnDocumentStateChanged() { //We assume that only the current document's state can be changed auto tabIndex = m_tabs.GetSelection(); assert(tabIndex != -1); auto documentId = m_tabs.GetTabData(tabIndex); auto documentIterator = m_documents.find(documentId); assert(documentIterator != std::end(m_documents)); if(documentIterator == std::end(m_documents)) return; auto document = dynamic_cast<IDocument*>(documentIterator->second.get()); assert(document); if(document == nullptr) return; auto documentName = document->GetName(); if(document->GetDirty()) { documentName += "*"; } m_tabs.SetTabText(tabIndex, string_cast<std::tstring>(documentName).c_str()); }
CPLErr GDALRasterBlock::Write() { if( !GetDirty() ) return CE_None; if( poBand == NULL ) return CE_Failure; MarkClean(); if (poBand->eFlushBlockErr == CE_None) { int bCallLeaveReadWrite = poBand->EnterReadWrite(GF_Write); CPLErr eErr = poBand->IWriteBlock( nXOff, nYOff, pData ); if( bCallLeaveReadWrite ) poBand->LeaveReadWrite(); return eErr; } else return poBand->eFlushBlockErr; }
bool WaveTrack::GetSpectrogram(float *freq, sampleCount *where, int numPixels, int height, double t0, double pixelsPerSecond, bool autocorrelation) { int maxFreq = gPrefs->Read(wxT("/Spectrum/MaxFreq"), 8000L);; if (mSpecCache && mSpecCache->maxFreqOld == maxFreq && mSpecCache->dirty == mDirty && mSpecCache->start == t0 && mSpecCache->ac == autocorrelation && mSpecCache->height == height && mSpecCache->len >= numPixels && mSpecCache->pps == pixelsPerSecond) { memcpy(freq, mSpecCache->freq, numPixels*height*sizeof(float)); memcpy(where, mSpecCache->where, (numPixels+1)*sizeof(sampleCount)); return true; } SpecCache *oldCache = mSpecCache; mSpecCache = new SpecCache(numPixels, height, autocorrelation); mSpecCache->pps = pixelsPerSecond; mSpecCache->start = t0; sampleCount x; bool *recalc = new bool[mSpecCache->len + 1]; for (x = 0; x < mSpecCache->len + 1; x++) { recalc[x] = true; mSpecCache->where[x] = (sampleCount)floor((t0*mRate) + (x*mRate/pixelsPerSecond) + 0.5); } // Optimization: if the old cache is good and overlaps // with the current one, re-use as much of the cache as // possible if (oldCache->dirty == GetDirty() && oldCache->maxFreqOld == maxFreq && oldCache->pps == pixelsPerSecond && oldCache->height == height && oldCache->ac == autocorrelation && oldCache->where[0] < mSpecCache->where[mSpecCache->len] && oldCache->where[oldCache->len] > mSpecCache->where[0]) { for (x = 0; x < mSpecCache->len; x++) if (mSpecCache->where[x] >= oldCache->where[0] && mSpecCache->where[x] <= oldCache->where[oldCache->len - 1]) { int ox = (int) ((double (oldCache->len) * (mSpecCache->where[x] - oldCache->where[0])) / (oldCache->where[oldCache->len] - oldCache->where[0]) + 0.5); if (ox >= 0 && ox <= oldCache->len && mSpecCache->where[x] == oldCache->where[ox]) { for (sampleCount i = 0; i < (sampleCount)height; i++) mSpecCache->freq[height * x + i] = oldCache->freq[height * ox + i]; recalc[x] = false; } } } int defaultMaxFreq = 8000; int defaultFFTSize = 256; #if (AUDACITY_BRANDING == BRAND_THINKLABS) // Thinklabs has lower default for Spectrum MaxFreq & bigger FFTSize than standard Audacity defaultMaxFreq = 1000; defaultFFTSize = 4096; #elif (AUDACITY_BRANDING == BRAND_AUDIOTOUCH) defaultMaxFreq = 3000; defaultFFTSize = 4096; #endif int windowSize = gPrefs->Read("/Spectrum/FFTSize", defaultFFTSize); float *buffer = new float[windowSize]; mSpecCache->maxFreqOld = maxFreq; for (x = 0; x < mSpecCache->len; x++) if (recalc[x]) { sampleCount start = mSpecCache->where[x]; sampleCount len = windowSize; sampleCount i; if (start >= mSequence->GetNumSamples()) { for (i = 0; i < (sampleCount)height; i++) mSpecCache->freq[height * x + i] = 0; } else { if (start + len > mSequence->GetNumSamples()) { len = mSequence->GetNumSamples() - start; for (i = len; i < (sampleCount)windowSize; i++) buffer[i] = 0; } mSequence->Get((samplePtr)buffer, floatSample, start, len); ComputeSpectrum(buffer, windowSize, height, maxFreq, windowSize, mRate, &mSpecCache->freq[height * x], autocorrelation); } } delete[]buffer; delete[]recalc; delete oldCache; mSpecCache->dirty = GetDirty(); memcpy(freq, mSpecCache->freq, numPixels*height*sizeof(float)); memcpy(where, mSpecCache->where, (numPixels+1)*sizeof(sampleCount)); return true; }