mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added a template to allow the HeapBlock class to be given signed ints or other types that are not size_t for its size parameters
This commit is contained in:
parent
13ccdf9411
commit
369d59f656
32 changed files with 189 additions and 199 deletions
|
|
@ -1092,7 +1092,7 @@ private:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
allocatedData.malloc ((size_t) numChannels + 1, sizeof (Type*));
|
allocatedData.malloc (numChannels + 1, sizeof (Type*));
|
||||||
channels = reinterpret_cast<Type**> (allocatedData.get());
|
channels = reinterpret_cast<Type**> (allocatedData.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1139,8 +1139,8 @@ public:
|
||||||
const int range = random.nextBool() ? 500 : 10;
|
const int range = random.nextBool() ? 500 : 10;
|
||||||
const int num = random.nextInt (range) + 1;
|
const int num = random.nextInt (range) + 1;
|
||||||
|
|
||||||
HeapBlock<ValueType> buffer1 ((size_t) num + 16), buffer2 ((size_t) num + 16);
|
HeapBlock<ValueType> buffer1 (num + 16), buffer2 (num + 16);
|
||||||
HeapBlock<int> buffer3 ((size_t) num + 16);
|
HeapBlock<int> buffer3 (num + 16);
|
||||||
|
|
||||||
#if JUCE_ARM
|
#if JUCE_ARM
|
||||||
ValueType* const data1 = buffer1;
|
ValueType* const data1 = buffer1;
|
||||||
|
|
|
||||||
|
|
@ -229,7 +229,7 @@ private:
|
||||||
if (size != bufferSize)
|
if (size != bufferSize)
|
||||||
{
|
{
|
||||||
bufferIndex = 0;
|
bufferIndex = 0;
|
||||||
buffer.malloc ((size_t) size);
|
buffer.malloc (size);
|
||||||
bufferSize = size;
|
bufferSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -274,7 +274,7 @@ private:
|
||||||
if (size != bufferSize)
|
if (size != bufferSize)
|
||||||
{
|
{
|
||||||
bufferIndex = 0;
|
bufferIndex = 0;
|
||||||
buffer.malloc ((size_t) size);
|
buffer.malloc (size);
|
||||||
bufferSize = size;
|
bufferSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -638,7 +638,7 @@ bool MidiMessage::isSysEx() const noexcept
|
||||||
|
|
||||||
MidiMessage MidiMessage::createSysExMessage (const void* sysexData, const int dataSize)
|
MidiMessage MidiMessage::createSysExMessage (const void* sysexData, const int dataSize)
|
||||||
{
|
{
|
||||||
HeapBlock<uint8> m ((size_t) dataSize + 2);
|
HeapBlock<uint8> m (dataSize + 2);
|
||||||
|
|
||||||
m[0] = 0xf0;
|
m[0] = 0xf0;
|
||||||
memcpy (m + 1, sysexData, (size_t) dataSize);
|
memcpy (m + 1, sysexData, (size_t) dataSize);
|
||||||
|
|
|
||||||
|
|
@ -52,14 +52,14 @@ void ResamplingAudioSource::prepareToPlay (int samplesPerBlockExpected, double s
|
||||||
{
|
{
|
||||||
const SpinLock::ScopedLockType sl (ratioLock);
|
const SpinLock::ScopedLockType sl (ratioLock);
|
||||||
|
|
||||||
const int scaledBlockSize = roundToInt (samplesPerBlockExpected * ratio);
|
auto scaledBlockSize = roundToInt (samplesPerBlockExpected * ratio);
|
||||||
input->prepareToPlay (scaledBlockSize, sampleRate * ratio);
|
input->prepareToPlay (scaledBlockSize, sampleRate * ratio);
|
||||||
|
|
||||||
buffer.setSize (numChannels, scaledBlockSize + 32);
|
buffer.setSize (numChannels, scaledBlockSize + 32);
|
||||||
|
|
||||||
filterStates.calloc ((size_t) numChannels);
|
filterStates.calloc (numChannels);
|
||||||
srcBuffers.calloc ((size_t) numChannels);
|
srcBuffers.calloc (numChannels);
|
||||||
destBuffers.calloc ((size_t) numChannels);
|
destBuffers.calloc (numChannels);
|
||||||
createLowPass (ratio);
|
createLowPass (ratio);
|
||||||
|
|
||||||
flushBuffers();
|
flushBuffers();
|
||||||
|
|
|
||||||
|
|
@ -316,8 +316,8 @@ private:
|
||||||
|
|
||||||
if (snd_midi_event_new (maxEventSize, &midiParser) >= 0)
|
if (snd_midi_event_new (maxEventSize, &midiParser) >= 0)
|
||||||
{
|
{
|
||||||
const int numPfds = snd_seq_poll_descriptors_count (seqHandle, POLLIN);
|
auto numPfds = snd_seq_poll_descriptors_count (seqHandle, POLLIN);
|
||||||
HeapBlock<pollfd> pfd ((size_t) numPfds);
|
HeapBlock<pollfd> pfd (numPfds);
|
||||||
snd_seq_poll_descriptors (seqHandle, pfd, (unsigned int) numPfds, POLLIN);
|
snd_seq_poll_descriptors (seqHandle, pfd, (unsigned int) numPfds, POLLIN);
|
||||||
|
|
||||||
HeapBlock<uint8> buffer (maxEventSize);
|
HeapBlock<uint8> buffer (maxEventSize);
|
||||||
|
|
|
||||||
|
|
@ -190,11 +190,11 @@ public:
|
||||||
|
|
||||||
void allocateTempBuffers()
|
void allocateTempBuffers()
|
||||||
{
|
{
|
||||||
const int tempBufSize = bufferSize + 4;
|
auto tempBufSize = bufferSize + 4;
|
||||||
audioBuffer.calloc ((size_t) ((numInputChans + numOutputChans) * tempBufSize));
|
audioBuffer.calloc ((numInputChans + numOutputChans) * tempBufSize);
|
||||||
|
|
||||||
tempInputBuffers.calloc ((size_t) numInputChans + 2);
|
tempInputBuffers.calloc (numInputChans + 2);
|
||||||
tempOutputBuffers.calloc ((size_t) numOutputChans + 2);
|
tempOutputBuffers.calloc (numOutputChans + 2);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < numInputChans; ++i) tempInputBuffers[i] = audioBuffer + count++ * tempBufSize;
|
for (int i = 0; i < numInputChans; ++i) tempInputBuffers[i] = audioBuffer + count++ * tempBufSize;
|
||||||
|
|
|
||||||
|
|
@ -440,7 +440,7 @@ public:
|
||||||
|
|
||||||
HeapBlock<int*> channels;
|
HeapBlock<int*> channels;
|
||||||
HeapBlock<int> temp;
|
HeapBlock<int> temp;
|
||||||
const int bitsToShift = 32 - (int) bitsPerSample;
|
auto bitsToShift = 32 - (int) bitsPerSample;
|
||||||
|
|
||||||
if (bitsToShift > 0)
|
if (bitsToShift > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -484,9 +484,9 @@ public:
|
||||||
void writeMetaData (const FlacNamespace::FLAC__StreamMetadata* metadata)
|
void writeMetaData (const FlacNamespace::FLAC__StreamMetadata* metadata)
|
||||||
{
|
{
|
||||||
using namespace FlacNamespace;
|
using namespace FlacNamespace;
|
||||||
const FLAC__StreamMetadata_StreamInfo& info = metadata->data.stream_info;
|
auto& info = metadata->data.stream_info;
|
||||||
|
|
||||||
unsigned char buffer [FLAC__STREAM_METADATA_STREAMINFO_LENGTH];
|
unsigned char buffer[FLAC__STREAM_METADATA_STREAMINFO_LENGTH];
|
||||||
const unsigned int channelsMinus1 = info.channels - 1;
|
const unsigned int channelsMinus1 = info.channels - 1;
|
||||||
const unsigned int bitsMinus1 = info.bits_per_sample - 1;
|
const unsigned int bitsMinus1 = info.bits_per_sample - 1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ void AudioFormatReader::read (AudioSampleBuffer* buffer,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HeapBlock<int*> chans ((size_t) numTargetChannels + 1);
|
HeapBlock<int*> chans (numTargetChannels + 1);
|
||||||
readChannels (*this, chans, buffer, startSample, numSamples, readerStartSample, numTargetChannels);
|
readChannels (*this, chans, buffer, startSample, numSamples, readerStartSample, numTargetChannels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,14 +89,12 @@ class AudioThumbnail::LevelDataSource : public TimeSliceClient
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LevelDataSource (AudioThumbnail& thumb, AudioFormatReader* newReader, int64 hash)
|
LevelDataSource (AudioThumbnail& thumb, AudioFormatReader* newReader, int64 hash)
|
||||||
: lengthInSamples (0), numSamplesFinished (0), sampleRate (0), numChannels (0),
|
: hashCode (hash), owner (thumb), reader (newReader)
|
||||||
hashCode (hash), owner (thumb), reader (newReader), lastReaderUseTime (0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
LevelDataSource (AudioThumbnail& thumb, InputSource* src)
|
LevelDataSource (AudioThumbnail& thumb, InputSource* src)
|
||||||
: lengthInSamples (0), numSamplesFinished (0), sampleRate (0), numChannels (0),
|
: hashCode (src->hashCode()), owner (thumb), source (src)
|
||||||
hashCode (src->hashCode()), owner (thumb), source (src), lastReaderUseTime (0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -179,7 +177,6 @@ public:
|
||||||
|
|
||||||
{
|
{
|
||||||
const ScopedLock sl (readerLock);
|
const ScopedLock sl (readerLock);
|
||||||
|
|
||||||
createReader();
|
createReader();
|
||||||
|
|
||||||
if (reader != nullptr)
|
if (reader != nullptr)
|
||||||
|
|
@ -207,17 +204,17 @@ public:
|
||||||
return (int) (originalSample / owner.samplesPerThumbSample);
|
return (int) (originalSample / owner.samplesPerThumbSample);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64 lengthInSamples, numSamplesFinished;
|
int64 lengthInSamples = 0, numSamplesFinished = 0;
|
||||||
double sampleRate;
|
double sampleRate = 0;
|
||||||
unsigned int numChannels;
|
unsigned int numChannels = 0;
|
||||||
int64 hashCode;
|
int64 hashCode = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AudioThumbnail& owner;
|
AudioThumbnail& owner;
|
||||||
ScopedPointer<InputSource> source;
|
ScopedPointer<InputSource> source;
|
||||||
ScopedPointer<AudioFormatReader> reader;
|
ScopedPointer<AudioFormatReader> reader;
|
||||||
CriticalSection readerLock;
|
CriticalSection readerLock;
|
||||||
uint32 lastReaderUseTime;
|
uint32 lastReaderUseTime = 0;
|
||||||
|
|
||||||
void createReader()
|
void createReader()
|
||||||
{
|
{
|
||||||
|
|
@ -232,23 +229,23 @@ private:
|
||||||
|
|
||||||
if (! isFullyLoaded())
|
if (! isFullyLoaded())
|
||||||
{
|
{
|
||||||
const int numToDo = (int) jmin (256 * (int64) owner.samplesPerThumbSample, lengthInSamples - numSamplesFinished);
|
auto numToDo = (int) jmin (256 * (int64) owner.samplesPerThumbSample, lengthInSamples - numSamplesFinished);
|
||||||
|
|
||||||
if (numToDo > 0)
|
if (numToDo > 0)
|
||||||
{
|
{
|
||||||
int64 startSample = numSamplesFinished;
|
auto startSample = numSamplesFinished;
|
||||||
|
|
||||||
const int firstThumbIndex = sampleToThumbSample (startSample);
|
auto firstThumbIndex = sampleToThumbSample (startSample);
|
||||||
const int lastThumbIndex = sampleToThumbSample (startSample + numToDo);
|
auto lastThumbIndex = sampleToThumbSample (startSample + numToDo);
|
||||||
const int numThumbSamps = lastThumbIndex - firstThumbIndex;
|
auto numThumbSamps = lastThumbIndex - firstThumbIndex;
|
||||||
|
|
||||||
HeapBlock<MinMaxValue> levelData ((size_t) numThumbSamps * numChannels);
|
HeapBlock<MinMaxValue> levelData ((unsigned int) numThumbSamps * numChannels);
|
||||||
HeapBlock<MinMaxValue*> levels (numChannels);
|
HeapBlock<MinMaxValue*> levels (numChannels);
|
||||||
|
|
||||||
for (int i = 0; i < (int) numChannels; ++i)
|
for (int i = 0; i < (int) numChannels; ++i)
|
||||||
levels[i] = levelData + i * numThumbSamps;
|
levels[i] = levelData + i * numThumbSamps;
|
||||||
|
|
||||||
HeapBlock<Range<float> > levelsRead (numChannels);
|
HeapBlock<Range<float>> levelsRead (numChannels);
|
||||||
|
|
||||||
for (int i = 0; i < numThumbSamps; ++i)
|
for (int i = 0; i < numThumbSamps; ++i)
|
||||||
{
|
{
|
||||||
|
|
@ -283,7 +280,7 @@ public:
|
||||||
ensureSize (numThumbSamples);
|
ensureSize (numThumbSamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline MinMaxValue* getData (const int thumbSampleIndex) noexcept
|
inline MinMaxValue* getData (int thumbSampleIndex) noexcept
|
||||||
{
|
{
|
||||||
jassert (thumbSampleIndex < data.size());
|
jassert (thumbSampleIndex < data.size());
|
||||||
return data.getRawDataPointer() + thumbSampleIndex;
|
return data.getRawDataPointer() + thumbSampleIndex;
|
||||||
|
|
@ -305,7 +302,7 @@ public:
|
||||||
|
|
||||||
while (startSample <= endSample)
|
while (startSample <= endSample)
|
||||||
{
|
{
|
||||||
const MinMaxValue& v = data.getReference (startSample);
|
auto& v = data.getReference (startSample);
|
||||||
|
|
||||||
if (v.getMinValue() < mn) mn = v.getMinValue();
|
if (v.getMinValue() < mn) mn = v.getMinValue();
|
||||||
if (v.getMaxValue() > mx) mx = v.getMaxValue();
|
if (v.getMaxValue() > mx) mx = v.getMaxValue();
|
||||||
|
|
@ -323,14 +320,14 @@ public:
|
||||||
result.set (1, 0);
|
result.set (1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void write (const MinMaxValue* const values, const int startIndex, const int numValues)
|
void write (const MinMaxValue* values, int startIndex, int numValues)
|
||||||
{
|
{
|
||||||
resetPeak();
|
resetPeak();
|
||||||
|
|
||||||
if (startIndex + numValues > data.size())
|
if (startIndex + numValues > data.size())
|
||||||
ensureSize (startIndex + numValues);
|
ensureSize (startIndex + numValues);
|
||||||
|
|
||||||
MinMaxValue* const dest = getData (startIndex);
|
auto* dest = getData (startIndex);
|
||||||
|
|
||||||
for (int i = 0; i < numValues; ++i)
|
for (int i = 0; i < numValues; ++i)
|
||||||
dest[i] = values[i];
|
dest[i] = values[i];
|
||||||
|
|
@ -345,9 +342,10 @@ public:
|
||||||
{
|
{
|
||||||
if (peakLevel < 0)
|
if (peakLevel < 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < data.size(); ++i)
|
for (auto& s : data)
|
||||||
{
|
{
|
||||||
const int peak = data[i].getPeak();
|
auto peak = s.getPeak();
|
||||||
|
|
||||||
if (peak > peakLevel)
|
if (peak > peakLevel)
|
||||||
peakLevel = peak;
|
peakLevel = peak;
|
||||||
}
|
}
|
||||||
|
|
@ -360,9 +358,10 @@ private:
|
||||||
Array<MinMaxValue> data;
|
Array<MinMaxValue> data;
|
||||||
int peakLevel;
|
int peakLevel;
|
||||||
|
|
||||||
void ensureSize (const int thumbSamples)
|
void ensureSize (int thumbSamples)
|
||||||
{
|
{
|
||||||
const int extraNeeded = thumbSamples - data.size();
|
auto extraNeeded = thumbSamples - data.size();
|
||||||
|
|
||||||
if (extraNeeded > 0)
|
if (extraNeeded > 0)
|
||||||
data.insertMultiple (-1, MinMaxValue(), extraNeeded);
|
data.insertMultiple (-1, MinMaxValue(), extraNeeded);
|
||||||
}
|
}
|
||||||
|
|
@ -372,12 +371,7 @@ private:
|
||||||
class AudioThumbnail::CachedWindow
|
class AudioThumbnail::CachedWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CachedWindow()
|
CachedWindow() {}
|
||||||
: cachedStart (0), cachedTimePerPixel (0),
|
|
||||||
numChannelsCached (0), numSamplesCached (0),
|
|
||||||
cacheNeedsRefilling (true)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void invalidate()
|
void invalidate()
|
||||||
{
|
{
|
||||||
|
|
@ -394,28 +388,28 @@ public:
|
||||||
numChans, sampsPerThumbSample, levelData, chans)
|
numChans, sampsPerThumbSample, levelData, chans)
|
||||||
&& isPositiveAndBelow (channelNum, numChannelsCached))
|
&& isPositiveAndBelow (channelNum, numChannelsCached))
|
||||||
{
|
{
|
||||||
const Rectangle<int> clip (g.getClipBounds().getIntersection (area.withWidth (jmin (numSamplesCached, area.getWidth()))));
|
auto clip = g.getClipBounds().getIntersection (area.withWidth (jmin (numSamplesCached, area.getWidth())));
|
||||||
|
|
||||||
if (! clip.isEmpty())
|
if (! clip.isEmpty())
|
||||||
{
|
{
|
||||||
const float topY = (float) area.getY();
|
auto topY = (float) area.getY();
|
||||||
const float bottomY = (float) area.getBottom();
|
auto bottomY = (float) area.getBottom();
|
||||||
const float midY = (topY + bottomY) * 0.5f;
|
auto midY = (topY + bottomY) * 0.5f;
|
||||||
const float vscale = verticalZoomFactor * (bottomY - topY) / 256.0f;
|
auto vscale = verticalZoomFactor * (bottomY - topY) / 256.0f;
|
||||||
|
|
||||||
const MinMaxValue* cacheData = getData (channelNum, clip.getX() - area.getX());
|
auto* cacheData = getData (channelNum, clip.getX() - area.getX());
|
||||||
|
|
||||||
RectangleList<float> waveform;
|
RectangleList<float> waveform;
|
||||||
waveform.ensureStorageAllocated (clip.getWidth());
|
waveform.ensureStorageAllocated (clip.getWidth());
|
||||||
|
|
||||||
float x = (float) clip.getX();
|
auto x = (float) clip.getX();
|
||||||
|
|
||||||
for (int w = clip.getWidth(); --w >= 0;)
|
for (int w = clip.getWidth(); --w >= 0;)
|
||||||
{
|
{
|
||||||
if (cacheData->isNonZero())
|
if (cacheData->isNonZero())
|
||||||
{
|
{
|
||||||
const float top = jmax (midY - cacheData->getMaxValue() * vscale - 0.3f, topY);
|
auto top = jmax (midY - cacheData->getMaxValue() * vscale - 0.3f, topY);
|
||||||
const float bottom = jmin (midY - cacheData->getMinValue() * vscale + 0.3f, bottomY);
|
auto bottom = jmin (midY - cacheData->getMinValue() * vscale + 0.3f, bottomY);
|
||||||
|
|
||||||
waveform.addWithoutMerging (Rectangle<float> (x, top, 1.0f, bottom - top));
|
waveform.addWithoutMerging (Rectangle<float> (x, top, 1.0f, bottom - top));
|
||||||
}
|
}
|
||||||
|
|
@ -431,15 +425,15 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Array<MinMaxValue> data;
|
Array<MinMaxValue> data;
|
||||||
double cachedStart, cachedTimePerPixel;
|
double cachedStart = 0, cachedTimePerPixel = 0;
|
||||||
int numChannelsCached, numSamplesCached;
|
int numChannelsCached = 0, numSamplesCached = 0;
|
||||||
bool cacheNeedsRefilling;
|
bool cacheNeedsRefilling = true;
|
||||||
|
|
||||||
bool refillCache (const int numSamples, double startTime, const double endTime,
|
bool refillCache (int numSamples, double startTime, double endTime,
|
||||||
const double rate, const int numChans, const int sampsPerThumbSample,
|
double rate, int numChans, int sampsPerThumbSample,
|
||||||
LevelDataSource* levelData, const OwnedArray<ThumbData>& chans)
|
LevelDataSource* levelData, const OwnedArray<ThumbData>& chans)
|
||||||
{
|
{
|
||||||
const double timePerPixel = (endTime - startTime) / numSamples;
|
auto timePerPixel = (endTime - startTime) / numSamples;
|
||||||
|
|
||||||
if (numSamples <= 0 || timePerPixel <= 0.0 || rate <= 0)
|
if (numSamples <= 0 || timePerPixel <= 0.0 || rate <= 0)
|
||||||
{
|
{
|
||||||
|
|
@ -466,13 +460,13 @@ private:
|
||||||
|
|
||||||
if (timePerPixel * rate <= sampsPerThumbSample && levelData != nullptr)
|
if (timePerPixel * rate <= sampsPerThumbSample && levelData != nullptr)
|
||||||
{
|
{
|
||||||
int sample = roundToInt (startTime * rate);
|
auto sample = roundToInt (startTime * rate);
|
||||||
Array<Range<float> > levels;
|
Array<Range<float>> levels;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < numSamples; ++i)
|
for (i = 0; i < numSamples; ++i)
|
||||||
{
|
{
|
||||||
const int nextSample = roundToInt ((startTime + timePerPixel) * rate);
|
auto nextSample = roundToInt ((startTime + timePerPixel) * rate);
|
||||||
|
|
||||||
if (sample >= 0)
|
if (sample >= 0)
|
||||||
{
|
{
|
||||||
|
|
@ -485,7 +479,7 @@ private:
|
||||||
{
|
{
|
||||||
levelData->getLevels (sample, jmax (1, nextSample - sample), levels);
|
levelData->getLevels (sample, jmax (1, nextSample - sample), levels);
|
||||||
|
|
||||||
const int totalChans = jmin (levels.size(), numChannelsCached);
|
auto totalChans = jmin (levels.size(), numChannelsCached);
|
||||||
|
|
||||||
for (int chan = 0; chan < totalChans; ++chan)
|
for (int chan = 0; chan < totalChans; ++chan)
|
||||||
getData (chan, i)->setFloat (levels.getReference (chan));
|
getData (chan, i)->setFloat (levels.getReference (chan));
|
||||||
|
|
@ -507,14 +501,14 @@ private:
|
||||||
ThumbData* channelData = chans.getUnchecked (channelNum);
|
ThumbData* channelData = chans.getUnchecked (channelNum);
|
||||||
MinMaxValue* cacheData = getData (channelNum, 0);
|
MinMaxValue* cacheData = getData (channelNum, 0);
|
||||||
|
|
||||||
const double timeToThumbSampleFactor = rate / (double) sampsPerThumbSample;
|
auto timeToThumbSampleFactor = rate / (double) sampsPerThumbSample;
|
||||||
|
|
||||||
startTime = cachedStart;
|
startTime = cachedStart;
|
||||||
int sample = roundToInt (startTime * timeToThumbSampleFactor);
|
auto sample = roundToInt (startTime * timeToThumbSampleFactor);
|
||||||
|
|
||||||
for (int i = numSamples; --i >= 0;)
|
for (int i = numSamples; --i >= 0;)
|
||||||
{
|
{
|
||||||
const int nextSample = roundToInt ((startTime + timePerPixel) * timeToThumbSampleFactor);
|
auto nextSample = roundToInt ((startTime + timePerPixel) * timeToThumbSampleFactor);
|
||||||
|
|
||||||
channelData->getMinMax (sample, nextSample, *cacheData);
|
channelData->getMinMax (sample, nextSample, *cacheData);
|
||||||
|
|
||||||
|
|
@ -538,7 +532,7 @@ private:
|
||||||
|
|
||||||
void ensureSize (const int numSamples)
|
void ensureSize (const int numSamples)
|
||||||
{
|
{
|
||||||
const int itemsRequired = numSamples * numChannelsCached;
|
auto itemsRequired = numSamples * numChannelsCached;
|
||||||
|
|
||||||
if (data.size() < itemsRequired)
|
if (data.size() < itemsRequired)
|
||||||
data.insertMultiple (-1, MinMaxValue(), itemsRequired - data.size());
|
data.insertMultiple (-1, MinMaxValue(), itemsRequired - data.size());
|
||||||
|
|
@ -552,11 +546,7 @@ AudioThumbnail::AudioThumbnail (const int originalSamplesPerThumbnailSample,
|
||||||
: formatManagerToUse (formatManager),
|
: formatManagerToUse (formatManager),
|
||||||
cache (cacheToUse),
|
cache (cacheToUse),
|
||||||
window (new CachedWindow()),
|
window (new CachedWindow()),
|
||||||
samplesPerThumbSample (originalSamplesPerThumbnailSample),
|
samplesPerThumbSample (originalSamplesPerThumbnailSample)
|
||||||
totalSamples (0),
|
|
||||||
numSamplesFinished (0),
|
|
||||||
numChannels (0),
|
|
||||||
sampleRate (0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -710,26 +700,26 @@ void AudioThumbnail::addBlock (const int64 startSample, const AudioSampleBuffer&
|
||||||
&& startOffsetInBuffer >= 0
|
&& startOffsetInBuffer >= 0
|
||||||
&& startOffsetInBuffer + numSamples <= incoming.getNumSamples());
|
&& startOffsetInBuffer + numSamples <= incoming.getNumSamples());
|
||||||
|
|
||||||
const int firstThumbIndex = (int) (startSample / samplesPerThumbSample);
|
auto firstThumbIndex = (int) (startSample / samplesPerThumbSample);
|
||||||
const int lastThumbIndex = (int) ((startSample + numSamples + (samplesPerThumbSample - 1)) / samplesPerThumbSample);
|
auto lastThumbIndex = (int) ((startSample + numSamples + (samplesPerThumbSample - 1)) / samplesPerThumbSample);
|
||||||
const int numToDo = lastThumbIndex - firstThumbIndex;
|
auto numToDo = lastThumbIndex - firstThumbIndex;
|
||||||
|
|
||||||
if (numToDo > 0)
|
if (numToDo > 0)
|
||||||
{
|
{
|
||||||
const int numChans = jmin (channels.size(), incoming.getNumChannels());
|
auto numChans = jmin (channels.size(), incoming.getNumChannels());
|
||||||
|
|
||||||
const HeapBlock<MinMaxValue> thumbData ((size_t) (numToDo * numChans));
|
const HeapBlock<MinMaxValue> thumbData (numToDo * numChans);
|
||||||
const HeapBlock<MinMaxValue*> thumbChannels ((size_t) numChans);
|
const HeapBlock<MinMaxValue*> thumbChannels (numChans);
|
||||||
|
|
||||||
for (int chan = 0; chan < numChans; ++chan)
|
for (int chan = 0; chan < numChans; ++chan)
|
||||||
{
|
{
|
||||||
const float* const sourceData = incoming.getReadPointer (chan, startOffsetInBuffer);
|
auto* sourceData = incoming.getReadPointer (chan, startOffsetInBuffer);
|
||||||
MinMaxValue* const dest = thumbData + numToDo * chan;
|
auto* dest = thumbData + numToDo * chan;
|
||||||
thumbChannels [chan] = dest;
|
thumbChannels [chan] = dest;
|
||||||
|
|
||||||
for (int i = 0; i < numToDo; ++i)
|
for (int i = 0; i < numToDo; ++i)
|
||||||
{
|
{
|
||||||
const int start = i * samplesPerThumbSample;
|
auto start = i * samplesPerThumbSample;
|
||||||
dest[i].setFloat (FloatVectorOperations::findMinAndMax (sourceData + start, jmin (samplesPerThumbSample, numSamples - start)));
|
dest[i].setFloat (FloatVectorOperations::findMinAndMax (sourceData + start, jmin (samplesPerThumbSample, numSamples - start)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -745,8 +735,8 @@ void AudioThumbnail::setLevels (const MinMaxValue* const* values, int thumbIndex
|
||||||
for (int i = jmin (numChans, channels.size()); --i >= 0;)
|
for (int i = jmin (numChans, channels.size()); --i >= 0;)
|
||||||
channels.getUnchecked(i)->write (values[i], thumbIndex, numValues);
|
channels.getUnchecked(i)->write (values[i], thumbIndex, numValues);
|
||||||
|
|
||||||
const int64 start = thumbIndex * (int64) samplesPerThumbSample;
|
auto start = thumbIndex * (int64) samplesPerThumbSample;
|
||||||
const int64 end = (thumbIndex + numValues) * (int64) samplesPerThumbSample;
|
auto end = (thumbIndex + numValues) * (int64) samplesPerThumbSample;
|
||||||
|
|
||||||
if (numSamplesFinished >= start && end > numSamplesFinished)
|
if (numSamplesFinished >= start && end > numSamplesFinished)
|
||||||
numSamplesFinished = end;
|
numSamplesFinished = end;
|
||||||
|
|
@ -787,23 +777,23 @@ float AudioThumbnail::getApproximatePeak() const
|
||||||
const ScopedLock sl (lock);
|
const ScopedLock sl (lock);
|
||||||
int peak = 0;
|
int peak = 0;
|
||||||
|
|
||||||
for (int i = channels.size(); --i >= 0;)
|
for (auto* c : channels)
|
||||||
peak = jmax (peak, channels.getUnchecked(i)->getPeak());
|
peak = jmax (peak, c->getPeak());
|
||||||
|
|
||||||
return jlimit (0, 127, peak) / 127.0f;
|
return jlimit (0, 127, peak) / 127.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioThumbnail::getApproximateMinMax (const double startTime, const double endTime, const int channelIndex,
|
void AudioThumbnail::getApproximateMinMax (double startTime, double endTime, int channelIndex,
|
||||||
float& minValue, float& maxValue) const noexcept
|
float& minValue, float& maxValue) const noexcept
|
||||||
{
|
{
|
||||||
const ScopedLock sl (lock);
|
const ScopedLock sl (lock);
|
||||||
MinMaxValue result;
|
MinMaxValue result;
|
||||||
const ThumbData* const data = channels [channelIndex];
|
auto* data = channels [channelIndex];
|
||||||
|
|
||||||
if (data != nullptr && sampleRate > 0)
|
if (data != nullptr && sampleRate > 0)
|
||||||
{
|
{
|
||||||
const int firstThumbIndex = (int) ((startTime * sampleRate) / samplesPerThumbSample);
|
auto firstThumbIndex = (int) ((startTime * sampleRate) / samplesPerThumbSample);
|
||||||
const int lastThumbIndex = (int) (((endTime * sampleRate) + samplesPerThumbSample - 1) / samplesPerThumbSample);
|
auto lastThumbIndex = (int) (((endTime * sampleRate) + samplesPerThumbSample - 1) / samplesPerThumbSample);
|
||||||
|
|
||||||
data->getMinMax (jmax (0, firstThumbIndex), lastThumbIndex, result);
|
data->getMinMax (jmax (0, firstThumbIndex), lastThumbIndex, result);
|
||||||
}
|
}
|
||||||
|
|
@ -826,10 +816,10 @@ void AudioThumbnail::drawChannels (Graphics& g, const Rectangle<int>& area, doub
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numChannels; ++i)
|
for (int i = 0; i < numChannels; ++i)
|
||||||
{
|
{
|
||||||
const int y1 = roundToInt ((i * area.getHeight()) / numChannels);
|
auto y1 = roundToInt ((i * area.getHeight()) / numChannels);
|
||||||
const int y2 = roundToInt (((i + 1) * area.getHeight()) / numChannels);
|
auto y2 = roundToInt (((i + 1) * area.getHeight()) / numChannels);
|
||||||
|
|
||||||
drawChannel (g, Rectangle<int> (area.getX(), area.getY() + y1, area.getWidth(), y2 - y1),
|
drawChannel (g, { area.getX(), area.getY() + y1, area.getWidth(), y2 - y1 },
|
||||||
startTimeSeconds, endTimeSeconds, i, verticalZoomFactor);
|
startTimeSeconds, endTimeSeconds, i, verticalZoomFactor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -210,10 +210,10 @@ private:
|
||||||
ScopedPointer<CachedWindow> window;
|
ScopedPointer<CachedWindow> window;
|
||||||
OwnedArray<ThumbData> channels;
|
OwnedArray<ThumbData> channels;
|
||||||
|
|
||||||
int32 samplesPerThumbSample;
|
int32 samplesPerThumbSample = 0;
|
||||||
int64 totalSamples, numSamplesFinished;
|
int64 totalSamples = 0, numSamplesFinished = 0;
|
||||||
int32 numChannels;
|
int32 numChannels = 0;
|
||||||
double sampleRate;
|
double sampleRate = 0;
|
||||||
CriticalSection lock;
|
CriticalSection lock;
|
||||||
|
|
||||||
void clearChannelData();
|
void clearChannelData();
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ void AudioProcessorPlayer::audioDeviceAboutToStart (AudioIODevice* const device)
|
||||||
numOutputChans = numChansOut;
|
numOutputChans = numChansOut;
|
||||||
|
|
||||||
messageCollector.reset (sampleRate);
|
messageCollector.reset (sampleRate);
|
||||||
channels.calloc ((size_t) jmax (numChansIn, numChansOut) + 2);
|
channels.calloc (jmax (numChansIn, numChansOut) + 2);
|
||||||
|
|
||||||
if (processor != nullptr)
|
if (processor != nullptr)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -245,10 +245,12 @@ struct Expression::Helpers
|
||||||
{
|
{
|
||||||
checkRecursionDepth (recursionDepth);
|
checkRecursionDepth (recursionDepth);
|
||||||
double result = 0;
|
double result = 0;
|
||||||
const int numParams = parameters.size();
|
auto numParams = parameters.size();
|
||||||
|
|
||||||
if (numParams > 0)
|
if (numParams > 0)
|
||||||
{
|
{
|
||||||
HeapBlock<double> params ((size_t) numParams);
|
HeapBlock<double> params (numParams);
|
||||||
|
|
||||||
for (int i = 0; i < numParams; ++i)
|
for (int i = 0; i < numParams; ++i)
|
||||||
params[i] = parameters.getReference(i).term->resolve (scope, recursionDepth + 1)->toDouble();
|
params[i] = parameters.getReference(i).term->resolve (scope, recursionDepth + 1)->toDouble();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ public:
|
||||||
After creation, you can resize the array using the malloc(), calloc(),
|
After creation, you can resize the array using the malloc(), calloc(),
|
||||||
or realloc() methods.
|
or realloc() methods.
|
||||||
*/
|
*/
|
||||||
HeapBlock() noexcept : data (nullptr)
|
HeapBlock() noexcept
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,8 +102,9 @@ public:
|
||||||
If you want an array of zero values, you can use the calloc() method or the
|
If you want an array of zero values, you can use the calloc() method or the
|
||||||
other constructor that takes an InitialisationState parameter.
|
other constructor that takes an InitialisationState parameter.
|
||||||
*/
|
*/
|
||||||
explicit HeapBlock (const size_t numElements)
|
template <typename SizeType>
|
||||||
: data (static_cast<ElementType*> (std::malloc (numElements * sizeof (ElementType))))
|
explicit HeapBlock (SizeType numElements)
|
||||||
|
: data (static_cast<ElementType*> (std::malloc (static_cast<size_t> (numElements) * sizeof (ElementType))))
|
||||||
{
|
{
|
||||||
throwOnAllocationFailure();
|
throwOnAllocationFailure();
|
||||||
}
|
}
|
||||||
|
|
@ -113,10 +114,11 @@ public:
|
||||||
The initialiseToZero parameter determines whether the new memory should be cleared,
|
The initialiseToZero parameter determines whether the new memory should be cleared,
|
||||||
or left uninitialised.
|
or left uninitialised.
|
||||||
*/
|
*/
|
||||||
HeapBlock (const size_t numElements, const bool initialiseToZero)
|
template <typename SizeType>
|
||||||
|
HeapBlock (SizeType numElements, bool initialiseToZero)
|
||||||
: data (static_cast<ElementType*> (initialiseToZero
|
: data (static_cast<ElementType*> (initialiseToZero
|
||||||
? std::calloc (numElements, sizeof (ElementType))
|
? std::calloc (static_cast<size_t> (numElements), sizeof (ElementType))
|
||||||
: std::malloc (numElements * sizeof (ElementType))))
|
: std::malloc (static_cast<size_t> (numElements) * sizeof (ElementType))))
|
||||||
{
|
{
|
||||||
throwOnAllocationFailure();
|
throwOnAllocationFailure();
|
||||||
}
|
}
|
||||||
|
|
@ -148,62 +150,61 @@ public:
|
||||||
This may be a null pointer if the data hasn't yet been allocated, or if it has been
|
This may be a null pointer if the data hasn't yet been allocated, or if it has been
|
||||||
freed by calling the free() method.
|
freed by calling the free() method.
|
||||||
*/
|
*/
|
||||||
inline operator ElementType*() const noexcept { return data; }
|
inline operator ElementType*() const noexcept { return data; }
|
||||||
|
|
||||||
|
|
||||||
/** Returns a raw pointer to the allocated data.
|
/** Returns a raw pointer to the allocated data.
|
||||||
This may be a null pointer if the data hasn't yet been allocated, or if it has been
|
This may be a null pointer if the data hasn't yet been allocated, or if it has been
|
||||||
freed by calling the free() method.
|
freed by calling the free() method.
|
||||||
*/
|
*/
|
||||||
inline ElementType* get() const noexcept { return data; }
|
inline ElementType* get() const noexcept { return data; }
|
||||||
|
|
||||||
/** Returns a raw pointer to the allocated data.
|
/** Returns a raw pointer to the allocated data.
|
||||||
This may be a null pointer if the data hasn't yet been allocated, or if it has been
|
This may be a null pointer if the data hasn't yet been allocated, or if it has been
|
||||||
freed by calling the free() method.
|
freed by calling the free() method.
|
||||||
*/
|
*/
|
||||||
inline ElementType* getData() const noexcept { return data; }
|
inline ElementType* getData() const noexcept { return data; }
|
||||||
|
|
||||||
/** Returns a void pointer to the allocated data.
|
/** Returns a void pointer to the allocated data.
|
||||||
This may be a null pointer if the data hasn't yet been allocated, or if it has been
|
This may be a null pointer if the data hasn't yet been allocated, or if it has been
|
||||||
freed by calling the free() method.
|
freed by calling the free() method.
|
||||||
*/
|
*/
|
||||||
inline operator void*() const noexcept { return static_cast<void*> (data); }
|
inline operator void*() const noexcept { return static_cast<void*> (data); }
|
||||||
|
|
||||||
/** Returns a void pointer to the allocated data.
|
/** Returns a void pointer to the allocated data.
|
||||||
This may be a null pointer if the data hasn't yet been allocated, or if it has been
|
This may be a null pointer if the data hasn't yet been allocated, or if it has been
|
||||||
freed by calling the free() method.
|
freed by calling the free() method.
|
||||||
*/
|
*/
|
||||||
inline operator const void*() const noexcept { return static_cast<const void*> (data); }
|
inline operator const void*() const noexcept { return static_cast<const void*> (data); }
|
||||||
|
|
||||||
/** Lets you use indirect calls to the first element in the array.
|
/** Lets you use indirect calls to the first element in the array.
|
||||||
Obviously this will cause problems if the array hasn't been initialised, because it'll
|
Obviously this will cause problems if the array hasn't been initialised, because it'll
|
||||||
be referencing a null pointer.
|
be referencing a null pointer.
|
||||||
*/
|
*/
|
||||||
inline ElementType* operator->() const noexcept { return data; }
|
inline ElementType* operator->() const noexcept { return data; }
|
||||||
|
|
||||||
/** Returns a reference to one of the data elements.
|
/** Returns a reference to one of the data elements.
|
||||||
Obviously there's no bounds-checking here, as this object is just a dumb pointer and
|
Obviously there's no bounds-checking here, as this object is just a dumb pointer and
|
||||||
has no idea of the size it currently has allocated.
|
has no idea of the size it currently has allocated.
|
||||||
*/
|
*/
|
||||||
template <typename IndexType>
|
template <typename IndexType>
|
||||||
inline ElementType& operator[] (IndexType index) const noexcept { return data [index]; }
|
ElementType& operator[] (IndexType index) const noexcept { return data [index]; }
|
||||||
|
|
||||||
/** Returns a pointer to a data element at an offset from the start of the array.
|
/** Returns a pointer to a data element at an offset from the start of the array.
|
||||||
This is the same as doing pointer arithmetic on the raw pointer itself.
|
This is the same as doing pointer arithmetic on the raw pointer itself.
|
||||||
*/
|
*/
|
||||||
template <typename IndexType>
|
template <typename IndexType>
|
||||||
inline ElementType* operator+ (IndexType index) const noexcept { return data + index; }
|
ElementType* operator+ (IndexType index) const noexcept { return data + index; }
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
/** Compares the pointer with another pointer.
|
/** Compares the pointer with another pointer.
|
||||||
This can be handy for checking whether this is a null pointer.
|
This can be handy for checking whether this is a null pointer.
|
||||||
*/
|
*/
|
||||||
inline bool operator== (const ElementType* const otherPointer) const noexcept { return otherPointer == data; }
|
inline bool operator== (const ElementType* otherPointer) const noexcept { return otherPointer == data; }
|
||||||
|
|
||||||
/** Compares the pointer with another pointer.
|
/** Compares the pointer with another pointer.
|
||||||
This can be handy for checking whether this is a null pointer.
|
This can be handy for checking whether this is a null pointer.
|
||||||
*/
|
*/
|
||||||
inline bool operator!= (const ElementType* const otherPointer) const noexcept { return otherPointer != data; }
|
inline bool operator!= (const ElementType* otherPointer) const noexcept { return otherPointer != data; }
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
/** Allocates a specified amount of memory.
|
/** Allocates a specified amount of memory.
|
||||||
|
|
@ -218,20 +219,22 @@ public:
|
||||||
The data that is allocated will be freed when this object is deleted, or when you
|
The data that is allocated will be freed when this object is deleted, or when you
|
||||||
call free() or any of the allocation methods.
|
call free() or any of the allocation methods.
|
||||||
*/
|
*/
|
||||||
void malloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
|
template <typename SizeType>
|
||||||
|
void malloc (SizeType newNumElements, size_t elementSize = sizeof (ElementType))
|
||||||
{
|
{
|
||||||
std::free (data);
|
std::free (data);
|
||||||
data = static_cast<ElementType*> (std::malloc (newNumElements * elementSize));
|
data = static_cast<ElementType*> (std::malloc (static_cast<size_t> (newNumElements) * elementSize));
|
||||||
throwOnAllocationFailure();
|
throwOnAllocationFailure();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Allocates a specified amount of memory and clears it.
|
/** Allocates a specified amount of memory and clears it.
|
||||||
This does the same job as the malloc() method, but clears the memory that it allocates.
|
This does the same job as the malloc() method, but clears the memory that it allocates.
|
||||||
*/
|
*/
|
||||||
void calloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
|
template <typename SizeType>
|
||||||
|
void calloc (SizeType newNumElements, const size_t elementSize = sizeof (ElementType))
|
||||||
{
|
{
|
||||||
std::free (data);
|
std::free (data);
|
||||||
data = static_cast<ElementType*> (std::calloc (newNumElements, elementSize));
|
data = static_cast<ElementType*> (std::calloc (static_cast<size_t> (newNumElements), elementSize));
|
||||||
throwOnAllocationFailure();
|
throwOnAllocationFailure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -239,12 +242,13 @@ public:
|
||||||
This does the same job as either malloc() or calloc(), depending on the
|
This does the same job as either malloc() or calloc(), depending on the
|
||||||
initialiseToZero parameter.
|
initialiseToZero parameter.
|
||||||
*/
|
*/
|
||||||
void allocate (const size_t newNumElements, bool initialiseToZero)
|
template <typename SizeType>
|
||||||
|
void allocate (SizeType newNumElements, bool initialiseToZero)
|
||||||
{
|
{
|
||||||
std::free (data);
|
std::free (data);
|
||||||
data = static_cast<ElementType*> (initialiseToZero
|
data = static_cast<ElementType*> (initialiseToZero
|
||||||
? std::calloc (newNumElements, sizeof (ElementType))
|
? std::calloc (static_cast<size_t> (newNumElements), sizeof (ElementType))
|
||||||
: std::malloc (newNumElements * sizeof (ElementType)));
|
: std::malloc (static_cast<size_t> (newNumElements) * sizeof (ElementType)));
|
||||||
throwOnAllocationFailure();
|
throwOnAllocationFailure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -253,10 +257,11 @@ public:
|
||||||
The semantics of this method are the same as malloc() and calloc(), but it
|
The semantics of this method are the same as malloc() and calloc(), but it
|
||||||
uses realloc() to keep as much of the existing data as possible.
|
uses realloc() to keep as much of the existing data as possible.
|
||||||
*/
|
*/
|
||||||
void realloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
|
template <typename SizeType>
|
||||||
|
void realloc (SizeType newNumElements, size_t elementSize = sizeof (ElementType))
|
||||||
{
|
{
|
||||||
data = static_cast<ElementType*> (data == nullptr ? std::malloc (newNumElements * elementSize)
|
data = static_cast<ElementType*> (data == nullptr ? std::malloc (static_cast<size_t> (newNumElements) * elementSize)
|
||||||
: std::realloc (data, newNumElements * elementSize));
|
: std::realloc (data, static_cast<size_t> (newNumElements) * elementSize));
|
||||||
throwOnAllocationFailure();
|
throwOnAllocationFailure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -282,9 +287,10 @@ public:
|
||||||
Since the block has no way of knowing its own size, you must make sure that the number of
|
Since the block has no way of knowing its own size, you must make sure that the number of
|
||||||
elements you specify doesn't exceed the allocated size.
|
elements you specify doesn't exceed the allocated size.
|
||||||
*/
|
*/
|
||||||
void clear (size_t numElements) noexcept
|
template <typename SizeType>
|
||||||
|
void clear (SizeType numElements) noexcept
|
||||||
{
|
{
|
||||||
zeromem (data, sizeof (ElementType) * numElements);
|
zeromem (data, sizeof (ElementType) * static_cast<size_t> (numElements));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This typedef can be used to get the type of the heapblock's elements. */
|
/** This typedef can be used to get the type of the heapblock's elements. */
|
||||||
|
|
@ -292,7 +298,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
ElementType* data;
|
ElementType* data = nullptr;
|
||||||
|
|
||||||
void throwOnAllocationFailure() const
|
void throwOnAllocationFailure() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -260,7 +260,7 @@ static void findIPAddresses (int sock, Array<IPAddress>& result)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
bufferSize *= 2;
|
bufferSize *= 2;
|
||||||
buffer.calloc ((size_t) bufferSize);
|
buffer.calloc (bufferSize);
|
||||||
|
|
||||||
cfg.ifc_len = bufferSize;
|
cfg.ifc_len = bufferSize;
|
||||||
cfg.ifc_buf = buffer;
|
cfg.ifc_buf = buffer;
|
||||||
|
|
|
||||||
|
|
@ -239,8 +239,8 @@ public:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int64 numBytesToSkip = wantedPos - position;
|
int64 numBytesToSkip = wantedPos - position;
|
||||||
const int skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384);
|
auto skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384);
|
||||||
HeapBlock<char> temp ((size_t) skipBufferSize);
|
HeapBlock<char> temp (skipBufferSize);
|
||||||
|
|
||||||
while (numBytesToSkip > 0 && ! isExhausted())
|
while (numBytesToSkip > 0 && ! isExhausted())
|
||||||
numBytesToSkip -= read (temp, (int) jmin (numBytesToSkip, (int64) skipBufferSize));
|
numBytesToSkip -= read (temp, (int) jmin (numBytesToSkip, (int64) skipBufferSize));
|
||||||
|
|
|
||||||
|
|
@ -1055,9 +1055,9 @@ public:
|
||||||
if (wantedPos < position)
|
if (wantedPos < position)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int64 numBytesToSkip = wantedPos - position;
|
auto numBytesToSkip = wantedPos - position;
|
||||||
const int skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384);
|
auto skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384);
|
||||||
HeapBlock<char> temp ((size_t) skipBufferSize);
|
HeapBlock<char> temp (skipBufferSize);
|
||||||
|
|
||||||
while (numBytesToSkip > 0 && ! isExhausted())
|
while (numBytesToSkip > 0 && ! isExhausted())
|
||||||
numBytesToSkip -= read (temp, (int) jmin (numBytesToSkip, (int64) skipBufferSize));
|
numBytesToSkip -= read (temp, (int) jmin (numBytesToSkip, (int64) skipBufferSize));
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ String String::fromCFString (CFStringRef cfString)
|
||||||
CFIndex bytesNeeded = 0;
|
CFIndex bytesNeeded = 0;
|
||||||
CFStringGetBytes (cfString, range, kCFStringEncodingUTF8, 0, false, nullptr, 0, &bytesNeeded);
|
CFStringGetBytes (cfString, range, kCFStringEncodingUTF8, 0, false, nullptr, 0, &bytesNeeded);
|
||||||
|
|
||||||
HeapBlock<UInt8> utf8 ((size_t) bytesNeeded + 1);
|
HeapBlock<UInt8> utf8 (bytesNeeded + 1);
|
||||||
CFStringGetBytes (cfString, range, kCFStringEncodingUTF8, 0, false, utf8, bytesNeeded + 1, nullptr);
|
CFStringGetBytes (cfString, range, kCFStringEncodingUTF8, 0, false, utf8, bytesNeeded + 1, nullptr);
|
||||||
|
|
||||||
return String (CharPointer_UTF8 ((const CharPointer_UTF8::CharType*) utf8.get()),
|
return String (CharPointer_UTF8 ((const CharPointer_UTF8::CharType*) utf8.get()),
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ public:
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
HeapBlock<char> buffer ((size_t) bufferSizeBytes);
|
HeapBlock<char> buffer (bufferSizeBytes);
|
||||||
|
|
||||||
if (HttpQueryInfo (request, HTTP_QUERY_RAW_HEADERS_CRLF, buffer.getData(), &bufferSizeBytes, 0))
|
if (HttpQueryInfo (request, HTTP_QUERY_RAW_HEADERS_CRLF, buffer.getData(), &bufferSizeBytes, 0))
|
||||||
{
|
{
|
||||||
|
|
@ -216,8 +216,8 @@ public:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int64 numBytesToSkip = wantedPos - position;
|
int64 numBytesToSkip = wantedPos - position;
|
||||||
const int skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384);
|
auto skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384);
|
||||||
HeapBlock<char> temp ((size_t) skipBufferSize);
|
HeapBlock<char> temp (skipBufferSize);
|
||||||
|
|
||||||
while (numBytesToSkip > 0 && ! isExhausted())
|
while (numBytesToSkip > 0 && ! isExhausted())
|
||||||
numBytesToSkip -= read (temp, (int) jmin (numBytesToSkip, (int64) skipBufferSize));
|
numBytesToSkip -= read (temp, (int) jmin (numBytesToSkip, (int64) skipBufferSize));
|
||||||
|
|
@ -645,7 +645,7 @@ bool JUCE_CALLTYPE Process::openEmailWithAttachments (const String& targetEmailA
|
||||||
message.lpRecips = &recip;
|
message.lpRecips = &recip;
|
||||||
|
|
||||||
HeapBlock<MapiFileDesc> files;
|
HeapBlock<MapiFileDesc> files;
|
||||||
files.calloc ((size_t) filesToAttach.size());
|
files.calloc (filesToAttach.size());
|
||||||
|
|
||||||
message.nFileCount = (ULONG) filesToAttach.size();
|
message.nFileCount = (ULONG) filesToAttach.size();
|
||||||
message.lpFiles = files;
|
message.lpFiles = files;
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ BufferedInputStream::BufferedInputStream (InputStream* sourceStream, int size, b
|
||||||
position (sourceStream->getPosition()),
|
position (sourceStream->getPosition()),
|
||||||
bufferStart (position)
|
bufferStart (position)
|
||||||
{
|
{
|
||||||
buffer.malloc ((size_t) bufferSize);
|
buffer.malloc (bufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferedInputStream::BufferedInputStream (InputStream& sourceStream, int size)
|
BufferedInputStream::BufferedInputStream (InputStream& sourceStream, int size)
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ String InputStream::readString()
|
||||||
String InputStream::readNextLine()
|
String InputStream::readNextLine()
|
||||||
{
|
{
|
||||||
MemoryBlock buffer (256);
|
MemoryBlock buffer (256);
|
||||||
char* data = static_cast<char*> (buffer.getData());
|
auto* data = static_cast<char*> (buffer.getData());
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
||||||
while ((data[i] = readByte()) != 0)
|
while ((data[i] = readByte()) != 0)
|
||||||
|
|
@ -223,8 +223,8 @@ void InputStream::skipNextBytes (int64 numBytesToSkip)
|
||||||
{
|
{
|
||||||
if (numBytesToSkip > 0)
|
if (numBytesToSkip > 0)
|
||||||
{
|
{
|
||||||
const int skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384);
|
auto skipBufferSize = (int) jmin (numBytesToSkip, (int64) 16384);
|
||||||
HeapBlock<char> temp ((size_t) skipBufferSize);
|
HeapBlock<char> temp (skipBufferSize);
|
||||||
|
|
||||||
while (numBytesToSkip > 0 && ! isExhausted())
|
while (numBytesToSkip > 0 && ! isExhausted())
|
||||||
numBytesToSkip -= read (temp, (int) jmin (numBytesToSkip, (int64) skipBufferSize));
|
numBytesToSkip -= read (temp, (int) jmin (numBytesToSkip, (int64) skipBufferSize));
|
||||||
|
|
|
||||||
|
|
@ -632,11 +632,11 @@ public:
|
||||||
void sortChildElements (ElementComparator& comparator,
|
void sortChildElements (ElementComparator& comparator,
|
||||||
bool retainOrderOfEquivalentItems = false)
|
bool retainOrderOfEquivalentItems = false)
|
||||||
{
|
{
|
||||||
const int num = getNumChildElements();
|
auto num = getNumChildElements();
|
||||||
|
|
||||||
if (num > 1)
|
if (num > 1)
|
||||||
{
|
{
|
||||||
HeapBlock<XmlElement*> elems ((size_t) num);
|
HeapBlock<XmlElement*> elems (num);
|
||||||
getChildElementsAsArray (elems);
|
getChildElementsAsArray (elems);
|
||||||
sortArray (comparator, (XmlElement**) elems, 0, num - 1, retainOrderOfEquivalentItems);
|
sortArray (comparator, (XmlElement**) elems, 0, num - 1, retainOrderOfEquivalentItems);
|
||||||
reorderChildElements (elems, num);
|
reorderChildElements (elems, num);
|
||||||
|
|
|
||||||
|
|
@ -37,20 +37,15 @@ ColourGradient::ColourGradient() noexcept
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ColourGradient::ColourGradient (Colour colour1, const float x1, const float y1,
|
ColourGradient::ColourGradient (Colour colour1, float x1, float y1,
|
||||||
Colour colour2, const float x2, const float y2,
|
Colour colour2, float x2, float y2, bool radial)
|
||||||
const bool radial)
|
: ColourGradient (colour1, Point<float> (x1, y1),
|
||||||
: point1 (x1, y1),
|
colour2, Point<float> (x2, y2), radial)
|
||||||
point2 (x2, y2),
|
|
||||||
isRadial (radial)
|
|
||||||
{
|
{
|
||||||
colours.add (ColourPoint (0.0, colour1));
|
|
||||||
colours.add (ColourPoint (1.0, colour2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ColourGradient::ColourGradient (Colour colour1, Point<float> p1,
|
ColourGradient::ColourGradient (Colour colour1, Point<float> p1,
|
||||||
Colour colour2, Point<float> p2,
|
Colour colour2, Point<float> p2, bool radial)
|
||||||
const bool radial)
|
|
||||||
: point1 (p1),
|
: point1 (p1),
|
||||||
point2 (p2),
|
point2 (p2),
|
||||||
isRadial (radial)
|
isRadial (radial)
|
||||||
|
|
@ -92,7 +87,7 @@ int ColourGradient::addColour (const double proportionAlongGradient, Colour colo
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const double pos = jmin (1.0, proportionAlongGradient);
|
auto pos = jmin (1.0, proportionAlongGradient);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < colours.size(); ++i)
|
for (i = 0; i < colours.size(); ++i)
|
||||||
|
|
@ -111,11 +106,8 @@ void ColourGradient::removeColour (int index)
|
||||||
|
|
||||||
void ColourGradient::multiplyOpacity (const float multiplier) noexcept
|
void ColourGradient::multiplyOpacity (const float multiplier) noexcept
|
||||||
{
|
{
|
||||||
for (int i = 0; i < colours.size(); ++i)
|
for (auto& c : colours)
|
||||||
{
|
c.colour = c.colour.withMultipliedAlpha (multiplier);
|
||||||
Colour& c = colours.getReference(i).colour;
|
|
||||||
c = c.withMultipliedAlpha (multiplier);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
@ -137,7 +129,7 @@ Colour ColourGradient::getColour (const int index) const noexcept
|
||||||
if (isPositiveAndBelow (index, colours.size()))
|
if (isPositiveAndBelow (index, colours.size()))
|
||||||
return colours.getReference (index).colour;
|
return colours.getReference (index).colour;
|
||||||
|
|
||||||
return Colour();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColourGradient::setColour (int index, Colour newColour) noexcept
|
void ColourGradient::setColour (int index, Colour newColour) noexcept
|
||||||
|
|
@ -175,14 +167,14 @@ void ColourGradient::createLookupTable (PixelARGB* const lookupTable, const int
|
||||||
jassert (numEntries > 0);
|
jassert (numEntries > 0);
|
||||||
jassert (colours.getReference(0).position == 0.0); // The first colour specified has to go at position 0
|
jassert (colours.getReference(0).position == 0.0); // The first colour specified has to go at position 0
|
||||||
|
|
||||||
PixelARGB pix1 (colours.getReference (0).colour.getPixelARGB());
|
auto pix1 = colours.getReference (0).colour.getPixelARGB();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
for (int j = 1; j < colours.size(); ++j)
|
for (int j = 1; j < colours.size(); ++j)
|
||||||
{
|
{
|
||||||
const ColourPoint& p = colours.getReference (j);
|
auto& p = colours.getReference (j);
|
||||||
const int numToDo = roundToInt (p.position * (numEntries - 1)) - index;
|
auto numToDo = roundToInt (p.position * (numEntries - 1)) - index;
|
||||||
const PixelARGB pix2 (p.colour.getPixelARGB());
|
auto pix2 = p.colour.getPixelARGB();
|
||||||
|
|
||||||
for (int i = 0; i < numToDo; ++i)
|
for (int i = 0; i < numToDo; ++i)
|
||||||
{
|
{
|
||||||
|
|
@ -205,18 +197,18 @@ int ColourGradient::createLookupTable (const AffineTransform& transform, HeapBlo
|
||||||
JUCE_COLOURGRADIENT_CHECK_COORDS_INITIALISED // Trying to use this object without setting its coordinates?
|
JUCE_COLOURGRADIENT_CHECK_COORDS_INITIALISED // Trying to use this object without setting its coordinates?
|
||||||
jassert (colours.size() >= 2);
|
jassert (colours.size() >= 2);
|
||||||
|
|
||||||
const int numEntries = jlimit (1, jmax (1, (colours.size() - 1) << 8),
|
auto numEntries = jlimit (1, jmax (1, (colours.size() - 1) << 8),
|
||||||
3 * (int) point1.transformedBy (transform)
|
3 * (int) point1.transformedBy (transform)
|
||||||
.getDistanceFrom (point2.transformedBy (transform)));
|
.getDistanceFrom (point2.transformedBy (transform)));
|
||||||
lookupTable.malloc ((size_t) numEntries);
|
lookupTable.malloc (numEntries);
|
||||||
createLookupTable (lookupTable, numEntries);
|
createLookupTable (lookupTable, numEntries);
|
||||||
return numEntries;
|
return numEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ColourGradient::isOpaque() const noexcept
|
bool ColourGradient::isOpaque() const noexcept
|
||||||
{
|
{
|
||||||
for (int i = 0; i < colours.size(); ++i)
|
for (auto& c : colours)
|
||||||
if (! colours.getReference(i).colour.isOpaque())
|
if (! c.colour.isOpaque())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -224,8 +216,8 @@ bool ColourGradient::isOpaque() const noexcept
|
||||||
|
|
||||||
bool ColourGradient::isInvisible() const noexcept
|
bool ColourGradient::isInvisible() const noexcept
|
||||||
{
|
{
|
||||||
for (int i = 0; i < colours.size(); ++i)
|
for (auto& c : colours)
|
||||||
if (! colours.getReference(i).colour.isTransparent())
|
if (! c.colour.isTransparent())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -545,7 +545,7 @@ bool PNGImageFormat::writeImageToStream (const Image& image, OutputStream& out)
|
||||||
PNG_COMPRESSION_TYPE_BASE,
|
PNG_COMPRESSION_TYPE_BASE,
|
||||||
PNG_FILTER_TYPE_BASE);
|
PNG_FILTER_TYPE_BASE);
|
||||||
|
|
||||||
HeapBlock<uint8> rowData ((size_t) width * 4);
|
HeapBlock<uint8> rowData (width * 4);
|
||||||
|
|
||||||
png_color_8 sig_bit;
|
png_color_8 sig_bit;
|
||||||
sig_bit.red = 8;
|
sig_bit.red = 8;
|
||||||
|
|
|
||||||
|
|
@ -247,7 +247,7 @@ bool CoreGraphicsContext::clipToRectangleListWithoutTest (const RectangleList<in
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t numRects = (size_t) clipRegion.getNumRectangles();
|
auto numRects = (size_t) clipRegion.getNumRectangles();
|
||||||
HeapBlock<CGRect> rects (numRects);
|
HeapBlock<CGRect> rects (numRects);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
@ -558,7 +558,7 @@ void CoreGraphicsContext::drawLine (const Line<float>& line)
|
||||||
|
|
||||||
void CoreGraphicsContext::fillRectList (const RectangleList<float>& list)
|
void CoreGraphicsContext::fillRectList (const RectangleList<float>& list)
|
||||||
{
|
{
|
||||||
HeapBlock<CGRect> rects ((size_t) list.getNumRectangles());
|
HeapBlock<CGRect> rects (list.getNumRectangles());
|
||||||
|
|
||||||
size_t num = 0;
|
size_t num = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ namespace CoreTextTypeLayout
|
||||||
{
|
{
|
||||||
if (advances == nullptr)
|
if (advances == nullptr)
|
||||||
{
|
{
|
||||||
local.malloc ((size_t) numGlyphs);
|
local.malloc (numGlyphs);
|
||||||
CTRunGetAdvances (run, CFRangeMake (0, 0), local);
|
CTRunGetAdvances (run, CFRangeMake (0, 0), local);
|
||||||
advances = local;
|
advances = local;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ struct FlexBoxLayoutCalculation
|
||||||
|| fb.flexDirection == FlexBox::Direction::rowReverse),
|
|| fb.flexDirection == FlexBox::Direction::rowReverse),
|
||||||
containerLineLength (isRowDirection ? parentWidth : parentHeight)
|
containerLineLength (isRowDirection ? parentWidth : parentHeight)
|
||||||
{
|
{
|
||||||
lineItems.calloc ((size_t) (numItems * numItems));
|
lineItems.calloc (numItems * numItems);
|
||||||
lineInfo.calloc ((size_t) numItems);
|
lineInfo.calloc (numItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ItemWithState
|
struct ItemWithState
|
||||||
|
|
|
||||||
|
|
@ -578,7 +578,7 @@ public:
|
||||||
const int pixStride = 2;
|
const int pixStride = 2;
|
||||||
const int stride = ((w * pixStride + 3) & ~3);
|
const int stride = ((w * pixStride + 3) & ~3);
|
||||||
|
|
||||||
imageData16Bit.malloc ((size_t) (stride * h));
|
imageData16Bit.malloc (stride * h);
|
||||||
xImage->data = imageData16Bit;
|
xImage->data = imageData16Bit;
|
||||||
xImage->bitmap_pad = 16;
|
xImage->bitmap_pad = 16;
|
||||||
xImage->depth = pixStride * 8;
|
xImage->depth = pixStride * 8;
|
||||||
|
|
@ -1946,7 +1946,7 @@ public:
|
||||||
void setIcon (const Image& newIcon) override
|
void setIcon (const Image& newIcon) override
|
||||||
{
|
{
|
||||||
const int dataSize = newIcon.getWidth() * newIcon.getHeight() + 2;
|
const int dataSize = newIcon.getWidth() * newIcon.getHeight() + 2;
|
||||||
HeapBlock<unsigned long> data ((size_t) dataSize);
|
HeapBlock<unsigned long> data (dataSize);
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
data[index++] = (unsigned long) newIcon.getWidth();
|
data[index++] = (unsigned long) newIcon.getWidth();
|
||||||
|
|
|
||||||
|
|
@ -3492,7 +3492,7 @@ private:
|
||||||
if (attributeSizeBytes > 0)
|
if (attributeSizeBytes > 0)
|
||||||
{
|
{
|
||||||
// Get attributes (8 bit flag per character):
|
// Get attributes (8 bit flag per character):
|
||||||
HeapBlock<char> attributes ((size_t) attributeSizeBytes);
|
HeapBlock<char> attributes (attributeSizeBytes);
|
||||||
ImmGetCompositionString (hImc, GCS_COMPATTR, attributes, (DWORD) attributeSizeBytes);
|
ImmGetCompositionString (hImc, GCS_COMPATTR, attributes, (DWORD) attributeSizeBytes);
|
||||||
|
|
||||||
selectionStart = 0;
|
selectionStart = 0;
|
||||||
|
|
|
||||||
|
|
@ -299,7 +299,7 @@ private:
|
||||||
: area (et.getMaximumBounds().withSize (nextPowerOfTwo (et.getMaximumBounds().getWidth()),
|
: area (et.getMaximumBounds().withSize (nextPowerOfTwo (et.getMaximumBounds().getWidth()),
|
||||||
nextPowerOfTwo (et.getMaximumBounds().getHeight())))
|
nextPowerOfTwo (et.getMaximumBounds().getHeight())))
|
||||||
{
|
{
|
||||||
data.calloc ((size_t) (area.getWidth() * area.getHeight()));
|
data.calloc (area.getWidth() * area.getHeight());
|
||||||
et.iterate (*this);
|
et.iterate (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,8 +103,8 @@ private:
|
||||||
|
|
||||||
static void verticalRowFlip (PixelARGB* const data, const int w, const int h)
|
static void verticalRowFlip (PixelARGB* const data, const int w, const int h)
|
||||||
{
|
{
|
||||||
HeapBlock<PixelARGB> tempRow ((size_t) w);
|
HeapBlock<PixelARGB> tempRow (w);
|
||||||
const size_t rowSize = sizeof (PixelARGB) * (size_t) w;
|
auto rowSize = sizeof (PixelARGB) * (size_t) w;
|
||||||
|
|
||||||
for (int y = 0; y < h / 2; ++y)
|
for (int y = 0; y < h / 2; ++y)
|
||||||
{
|
{
|
||||||
|
|
@ -125,8 +125,8 @@ private:
|
||||||
|
|
||||||
void write (const PixelARGB* const data) const noexcept
|
void write (const PixelARGB* const data) const noexcept
|
||||||
{
|
{
|
||||||
HeapBlock<PixelARGB> invertedCopy ((size_t) (area.getWidth() * area.getHeight()));
|
HeapBlock<PixelARGB> invertedCopy (area.getWidth() * area.getHeight());
|
||||||
const size_t rowSize = sizeof (PixelARGB) * (size_t) area.getWidth();
|
auto rowSize = sizeof (PixelARGB) * (size_t) area.getWidth();
|
||||||
|
|
||||||
for (int y = 0; y < area.getHeight(); ++y)
|
for (int y = 0; y < area.getHeight(); ++y)
|
||||||
memcpy (invertedCopy + area.getWidth() * y,
|
memcpy (invertedCopy + area.getWidth() * y,
|
||||||
|
|
|
||||||
|
|
@ -107,12 +107,12 @@ struct Flipper
|
||||||
static void flip (HeapBlock<PixelARGB>& dataCopy, const uint8* srcData, const int lineStride,
|
static void flip (HeapBlock<PixelARGB>& dataCopy, const uint8* srcData, const int lineStride,
|
||||||
const int w, const int h)
|
const int w, const int h)
|
||||||
{
|
{
|
||||||
dataCopy.malloc ((size_t) (w * h));
|
dataCopy.malloc (w * h);
|
||||||
|
|
||||||
for (int y = 0; y < h; ++y)
|
for (int y = 0; y < h; ++y)
|
||||||
{
|
{
|
||||||
const PixelType* src = (const PixelType*) srcData;
|
auto* src = (const PixelType*) srcData;
|
||||||
PixelARGB* const dst = (PixelARGB*) (dataCopy + w * (h - 1 - y));
|
auto* dst = (PixelARGB*) (dataCopy + w * (h - 1 - y));
|
||||||
|
|
||||||
for (int x = 0; x < w; ++x)
|
for (int x = 0; x < w; ++x)
|
||||||
dst[x].set (src[x]);
|
dst[x].set (src[x]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue